diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json b/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json index da6a576f460f..19bdbeb34e4b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "6d859b77c6378a5a186c8adf69cac60776d537bb", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.7", + "@autorest/modelerfour@4.24.3" ], - "commit": "2f2b633d940230cbbd5bcf1339a2e1c48674e4a2", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/containerregistry/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/containerregistry/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/containerregistry/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/__init__.py index 4bf92c7f4331..48db7faeef87 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py index 8ab432d3a36a..5fbe384ada9c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ContainerRegistryManagementClientConfiguration(Configuration): @@ -28,19 +26,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): 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 Microsoft Azure subscription ID. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any ): - # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -55,9 +52,8 @@ def __init__( def _configure( self, - **kwargs # type: Any + **kwargs: 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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py index 751fb46e7b32..0424774e4541 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ContainerRegistryManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :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 Microsoft Azure subscription ID. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -56,7 +53,7 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-12-01' _PROFILE_TAG = "azure.mgmt.containerregistry.ContainerRegistryManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -74,12 +71,12 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str - profile=KnownProfiles.default, # type: KnownProfiles - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + api_version: Optional[str]=None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles=KnownProfiles.default, + **kwargs: Any ): self._config = ContainerRegistryManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -111,6 +108,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01: :mod:`v2021_09_01.models` * 2021-12-01-preview: :mod:`v2021_12_01_preview.models` * 2022-02-01-preview: :mod:`v2022_02_01_preview.models` + * 2022-12-01: :mod:`v2022_12_01.models` + * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` """ if api_version == '2017-03-01': from .v2017_03_01 import models @@ -157,6 +156,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-02-01-preview': from .v2022_02_01_preview import models return models + elif api_version == '2022-12-01': + from .v2022_12_01 import models + return models + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -170,6 +175,7 @@ def agent_pools(self): from .v2019_06_01_preview.operations import AgentPoolsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'agent_pools'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -183,6 +189,7 @@ def build_steps(self): from .v2018_02_01_preview.operations import BuildStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_steps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -196,6 +203,7 @@ def build_tasks(self): from .v2018_02_01_preview.operations import BuildTasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -209,6 +217,21 @@ def builds(self): from .v2018_02_01_preview.operations import BuildsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'builds'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def cache_rules(self): + """Instance depends on the API version: + + * 2023-01-01-preview: :class:`CacheRulesOperations` + """ + api_version = self._get_api_version('cache_rules') + if api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import CacheRulesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'cache_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -220,6 +243,7 @@ def connected_registries(self): * 2021-08-01-preview: :class:`ConnectedRegistriesOperations` * 2021-12-01-preview: :class:`ConnectedRegistriesOperations` * 2022-02-01-preview: :class:`ConnectedRegistriesOperations` + * 2023-01-01-preview: :class:`ConnectedRegistriesOperations` """ api_version = self._get_api_version('connected_registries') if api_version == '2020-11-01-preview': @@ -232,8 +256,25 @@ def connected_registries(self): from .v2021_12_01_preview.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import ConnectedRegistriesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import ConnectedRegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'connected_registries'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def credential_sets(self): + """Instance depends on the API version: + + * 2023-01-01-preview: :class:`CredentialSetsOperations` + """ + api_version = self._get_api_version('credential_sets') + if api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import CredentialSetsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'credential_sets'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -246,6 +287,7 @@ def export_pipelines(self): * 2021-08-01-preview: :class:`ExportPipelinesOperations` * 2021-12-01-preview: :class:`ExportPipelinesOperations` * 2022-02-01-preview: :class:`ExportPipelinesOperations` + * 2023-01-01-preview: :class:`ExportPipelinesOperations` """ api_version = self._get_api_version('export_pipelines') if api_version == '2019-12-01-preview': @@ -260,8 +302,11 @@ def export_pipelines(self): from .v2021_12_01_preview.operations import ExportPipelinesOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import ExportPipelinesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import ExportPipelinesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'export_pipelines'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -274,6 +319,7 @@ def import_pipelines(self): * 2021-08-01-preview: :class:`ImportPipelinesOperations` * 2021-12-01-preview: :class:`ImportPipelinesOperations` * 2022-02-01-preview: :class:`ImportPipelinesOperations` + * 2023-01-01-preview: :class:`ImportPipelinesOperations` """ api_version = self._get_api_version('import_pipelines') if api_version == '2019-12-01-preview': @@ -288,8 +334,11 @@ def import_pipelines(self): from .v2021_12_01_preview.operations import ImportPipelinesOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import ImportPipelinesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import ImportPipelinesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'import_pipelines'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -306,6 +355,8 @@ def operations(self): * 2021-09-01: :class:`Operations` * 2021-12-01-preview: :class:`Operations` * 2022-02-01-preview: :class:`Operations` + * 2022-12-01: :class:`Operations` + * 2023-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-03-01': @@ -328,8 +379,13 @@ def operations(self): from .v2021_12_01_preview.operations import Operations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import Operations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import Operations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -342,6 +398,7 @@ def pipeline_runs(self): * 2021-08-01-preview: :class:`PipelineRunsOperations` * 2021-12-01-preview: :class:`PipelineRunsOperations` * 2022-02-01-preview: :class:`PipelineRunsOperations` + * 2023-01-01-preview: :class:`PipelineRunsOperations` """ api_version = self._get_api_version('pipeline_runs') if api_version == '2019-12-01-preview': @@ -356,8 +413,11 @@ def pipeline_runs(self): from .v2021_12_01_preview.operations import PipelineRunsOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import PipelineRunsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import PipelineRunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'pipeline_runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -371,6 +431,8 @@ def private_endpoint_connections(self): * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` * 2021-12-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2022-02-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-12-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-01-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-12-01-preview': @@ -387,8 +449,13 @@ def private_endpoint_connections(self): from .v2021_12_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -410,6 +477,8 @@ def registries(self): * 2021-09-01: :class:`RegistriesOperations` * 2021-12-01-preview: :class:`RegistriesOperations` * 2022-02-01-preview: :class:`RegistriesOperations` + * 2022-12-01: :class:`RegistriesOperations` + * 2023-01-01-preview: :class:`RegistriesOperations` """ api_version = self._get_api_version('registries') if api_version == '2017-03-01': @@ -442,8 +511,13 @@ def registries(self): from .v2021_12_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import RegistriesOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import RegistriesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import RegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'registries'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -459,6 +533,8 @@ def replications(self): * 2021-09-01: :class:`ReplicationsOperations` * 2021-12-01-preview: :class:`ReplicationsOperations` * 2022-02-01-preview: :class:`ReplicationsOperations` + * 2022-12-01: :class:`ReplicationsOperations` + * 2023-01-01-preview: :class:`ReplicationsOperations` """ api_version = self._get_api_version('replications') if api_version == '2017-10-01': @@ -479,8 +555,13 @@ def replications(self): from .v2021_12_01_preview.operations import ReplicationsOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import ReplicationsOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import ReplicationsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import ReplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'replications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -500,6 +581,7 @@ def runs(self): from .v2019_06_01_preview.operations import RunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -512,6 +594,8 @@ def scope_maps(self): * 2021-08-01-preview: :class:`ScopeMapsOperations` * 2021-12-01-preview: :class:`ScopeMapsOperations` * 2022-02-01-preview: :class:`ScopeMapsOperations` + * 2022-12-01: :class:`ScopeMapsOperations` + * 2023-01-01-preview: :class:`ScopeMapsOperations` """ api_version = self._get_api_version('scope_maps') if api_version == '2019-05-01-preview': @@ -526,8 +610,13 @@ def scope_maps(self): from .v2021_12_01_preview.operations import ScopeMapsOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import ScopeMapsOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import ScopeMapsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import ScopeMapsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_maps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -541,6 +630,7 @@ def task_runs(self): from .v2019_06_01_preview.operations import TaskRunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'task_runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -560,6 +650,7 @@ def tasks(self): from .v2019_06_01_preview.operations import TasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -572,6 +663,8 @@ def tokens(self): * 2021-08-01-preview: :class:`TokensOperations` * 2021-12-01-preview: :class:`TokensOperations` * 2022-02-01-preview: :class:`TokensOperations` + * 2022-12-01: :class:`TokensOperations` + * 2023-01-01-preview: :class:`TokensOperations` """ api_version = self._get_api_version('tokens') if api_version == '2019-05-01-preview': @@ -586,8 +679,13 @@ def tokens(self): from .v2021_12_01_preview.operations import TokensOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import TokensOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import TokensOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import TokensOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tokens'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -603,6 +701,8 @@ def webhooks(self): * 2021-09-01: :class:`WebhooksOperations` * 2021-12-01-preview: :class:`WebhooksOperations` * 2022-02-01-preview: :class:`WebhooksOperations` + * 2022-12-01: :class:`WebhooksOperations` + * 2023-01-01-preview: :class:`WebhooksOperations` """ api_version = self._get_api_version('webhooks') if api_version == '2017-10-01': @@ -623,8 +723,13 @@ def webhooks(self): from .v2021_12_01_preview.operations import WebhooksOperations as OperationClass elif api_version == '2022-02-01-preview': from .v2022_02_01_preview.operations import WebhooksOperations as OperationClass + elif api_version == '2022-12-01': + from .v2022_12_01.operations import WebhooksOperations as OperationClass + elif api_version == '2023-01-01-preview': + from .v2023_01_01_preview.operations import WebhooksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'webhooks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py new file mode 100644 index 000000000000..2c170e28dbca --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py @@ -0,0 +1,1967 @@ +# -------------------------------------------------------------------------- +# +# 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 +# pyright: reportUnnecessaryTypeIgnoreComment=false + +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 +from typing import Optional, Union, AnyStr, IO, Mapping + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from typing import Dict, Any, cast + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + + +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: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + 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: Optional[Union[AnyStr, IO]], headers: 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 + unicode_str = str + +_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 # type: ignore +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 +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) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + 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) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _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 = [ # type: ignore + 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): # type: ignore + # 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) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + 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 # type: ignore + 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 # type: ignore + 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.debug( + "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) # type: ignore + 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) # type: ignore + 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): # type: ignore + 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)) # type: ignore + + @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) # type: ignore + attr = attr + padding # type: ignore + 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) # type: ignore + 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) # type: ignore + + @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): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @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): # type: ignore + 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) # type: ignore + 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() # type: ignore + 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) # type: ignore + 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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_configuration.py index 3322771933cc..32a7349527a5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_configuration.py @@ -26,9 +26,9 @@ class ContainerRegistryManagementClientConfiguration(Configuration): 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 Microsoft Azure subscription ID. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str """ @@ -36,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_container_registry_management_client.py index e5f8d6425daf..ef3d4e04f30f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_container_registry_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :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 Microsoft Azure subscription ID. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -55,7 +53,7 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-12-01' _PROFILE_TAG = "azure.mgmt.containerregistry.ContainerRegistryManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -78,7 +76,7 @@ def __init__( api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, - **kwargs # type: Any + **kwargs: Any ) -> None: self._config = ContainerRegistryManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -110,6 +108,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01: :mod:`v2021_09_01.models` * 2021-12-01-preview: :mod:`v2021_12_01_preview.models` * 2022-02-01-preview: :mod:`v2022_02_01_preview.models` + * 2022-12-01: :mod:`v2022_12_01.models` + * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` """ if api_version == '2017-03-01': from ..v2017_03_01 import models @@ -156,6 +156,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview import models return models + elif api_version == '2022-12-01': + from ..v2022_12_01 import models + return models + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -169,6 +175,7 @@ def agent_pools(self): from ..v2019_06_01_preview.aio.operations import AgentPoolsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'agent_pools'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -182,6 +189,7 @@ def build_steps(self): from ..v2018_02_01_preview.aio.operations import BuildStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_steps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -195,6 +203,7 @@ def build_tasks(self): from ..v2018_02_01_preview.aio.operations import BuildTasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'build_tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -208,6 +217,21 @@ def builds(self): from ..v2018_02_01_preview.aio.operations import BuildsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'builds'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def cache_rules(self): + """Instance depends on the API version: + + * 2023-01-01-preview: :class:`CacheRulesOperations` + """ + api_version = self._get_api_version('cache_rules') + if api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import CacheRulesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'cache_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -219,6 +243,7 @@ def connected_registries(self): * 2021-08-01-preview: :class:`ConnectedRegistriesOperations` * 2021-12-01-preview: :class:`ConnectedRegistriesOperations` * 2022-02-01-preview: :class:`ConnectedRegistriesOperations` + * 2023-01-01-preview: :class:`ConnectedRegistriesOperations` """ api_version = self._get_api_version('connected_registries') if api_version == '2020-11-01-preview': @@ -231,8 +256,25 @@ def connected_registries(self): from ..v2021_12_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'connected_registries'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def credential_sets(self): + """Instance depends on the API version: + + * 2023-01-01-preview: :class:`CredentialSetsOperations` + """ + api_version = self._get_api_version('credential_sets') + if api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import CredentialSetsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'credential_sets'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -245,6 +287,7 @@ def export_pipelines(self): * 2021-08-01-preview: :class:`ExportPipelinesOperations` * 2021-12-01-preview: :class:`ExportPipelinesOperations` * 2022-02-01-preview: :class:`ExportPipelinesOperations` + * 2023-01-01-preview: :class:`ExportPipelinesOperations` """ api_version = self._get_api_version('export_pipelines') if api_version == '2019-12-01-preview': @@ -259,8 +302,11 @@ def export_pipelines(self): from ..v2021_12_01_preview.aio.operations import ExportPipelinesOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import ExportPipelinesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import ExportPipelinesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'export_pipelines'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -273,6 +319,7 @@ def import_pipelines(self): * 2021-08-01-preview: :class:`ImportPipelinesOperations` * 2021-12-01-preview: :class:`ImportPipelinesOperations` * 2022-02-01-preview: :class:`ImportPipelinesOperations` + * 2023-01-01-preview: :class:`ImportPipelinesOperations` """ api_version = self._get_api_version('import_pipelines') if api_version == '2019-12-01-preview': @@ -287,8 +334,11 @@ def import_pipelines(self): from ..v2021_12_01_preview.aio.operations import ImportPipelinesOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import ImportPipelinesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import ImportPipelinesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'import_pipelines'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -305,6 +355,8 @@ def operations(self): * 2021-09-01: :class:`Operations` * 2021-12-01-preview: :class:`Operations` * 2022-02-01-preview: :class:`Operations` + * 2022-12-01: :class:`Operations` + * 2023-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-03-01': @@ -327,8 +379,13 @@ def operations(self): from ..v2021_12_01_preview.aio.operations import Operations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import Operations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -341,6 +398,7 @@ def pipeline_runs(self): * 2021-08-01-preview: :class:`PipelineRunsOperations` * 2021-12-01-preview: :class:`PipelineRunsOperations` * 2022-02-01-preview: :class:`PipelineRunsOperations` + * 2023-01-01-preview: :class:`PipelineRunsOperations` """ api_version = self._get_api_version('pipeline_runs') if api_version == '2019-12-01-preview': @@ -355,8 +413,11 @@ def pipeline_runs(self): from ..v2021_12_01_preview.aio.operations import PipelineRunsOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import PipelineRunsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import PipelineRunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'pipeline_runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -370,6 +431,8 @@ def private_endpoint_connections(self): * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` * 2021-12-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2022-02-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-12-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-01-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-12-01-preview': @@ -386,8 +449,13 @@ def private_endpoint_connections(self): from ..v2021_12_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -409,6 +477,8 @@ def registries(self): * 2021-09-01: :class:`RegistriesOperations` * 2021-12-01-preview: :class:`RegistriesOperations` * 2022-02-01-preview: :class:`RegistriesOperations` + * 2022-12-01: :class:`RegistriesOperations` + * 2023-01-01-preview: :class:`RegistriesOperations` """ api_version = self._get_api_version('registries') if api_version == '2017-03-01': @@ -441,8 +511,13 @@ def registries(self): from ..v2021_12_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import RegistriesOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import RegistriesOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import RegistriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'registries'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -458,6 +533,8 @@ def replications(self): * 2021-09-01: :class:`ReplicationsOperations` * 2021-12-01-preview: :class:`ReplicationsOperations` * 2022-02-01-preview: :class:`ReplicationsOperations` + * 2022-12-01: :class:`ReplicationsOperations` + * 2023-01-01-preview: :class:`ReplicationsOperations` """ api_version = self._get_api_version('replications') if api_version == '2017-10-01': @@ -478,8 +555,13 @@ def replications(self): from ..v2021_12_01_preview.aio.operations import ReplicationsOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import ReplicationsOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import ReplicationsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import ReplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'replications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -499,6 +581,7 @@ def runs(self): from ..v2019_06_01_preview.aio.operations import RunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -511,6 +594,8 @@ def scope_maps(self): * 2021-08-01-preview: :class:`ScopeMapsOperations` * 2021-12-01-preview: :class:`ScopeMapsOperations` * 2022-02-01-preview: :class:`ScopeMapsOperations` + * 2022-12-01: :class:`ScopeMapsOperations` + * 2023-01-01-preview: :class:`ScopeMapsOperations` """ api_version = self._get_api_version('scope_maps') if api_version == '2019-05-01-preview': @@ -525,8 +610,13 @@ def scope_maps(self): from ..v2021_12_01_preview.aio.operations import ScopeMapsOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import ScopeMapsOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import ScopeMapsOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import ScopeMapsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_maps'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -540,6 +630,7 @@ def task_runs(self): from ..v2019_06_01_preview.aio.operations import TaskRunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'task_runs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -559,6 +650,7 @@ def tasks(self): from ..v2019_06_01_preview.aio.operations import TasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -571,6 +663,8 @@ def tokens(self): * 2021-08-01-preview: :class:`TokensOperations` * 2021-12-01-preview: :class:`TokensOperations` * 2022-02-01-preview: :class:`TokensOperations` + * 2022-12-01: :class:`TokensOperations` + * 2023-01-01-preview: :class:`TokensOperations` """ api_version = self._get_api_version('tokens') if api_version == '2019-05-01-preview': @@ -585,8 +679,13 @@ def tokens(self): from ..v2021_12_01_preview.aio.operations import TokensOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import TokensOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import TokensOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import TokensOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tokens'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -602,6 +701,8 @@ def webhooks(self): * 2021-09-01: :class:`WebhooksOperations` * 2021-12-01-preview: :class:`WebhooksOperations` * 2022-02-01-preview: :class:`WebhooksOperations` + * 2022-12-01: :class:`WebhooksOperations` + * 2023-01-01-preview: :class:`WebhooksOperations` """ api_version = self._get_api_version('webhooks') if api_version == '2017-10-01': @@ -622,8 +723,13 @@ def webhooks(self): from ..v2021_12_01_preview.aio.operations import WebhooksOperations as OperationClass elif api_version == '2022-02-01-preview': from ..v2022_02_01_preview.aio.operations import WebhooksOperations as OperationClass + elif api_version == '2022-12-01': + from ..v2022_12_01.aio.operations import WebhooksOperations as OperationClass + elif api_version == '2023-01-01-preview': + from ..v2023_01_01_preview.aio.operations import WebhooksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'webhooks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py index 70c2d2932382..ab476829d861 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py @@ -7,4 +7,4 @@ from .v2018_02_01_preview.models import * from .v2019_04_01.models import * from .v2019_06_01_preview.models import * -from .v2021_09_01.models import * +from .v2022_12_01.models import * diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_configuration.py index 4f730649ea46..85434543739c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-03-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", "2017-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_container_registry_management_client.py index 0776cfd52375..5765802991b8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations @@ -22,16 +21,17 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations :vartype registries: azure.mgmt.containerregistry.v2017_03_01.operations.RegistriesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.containerregistry.v2017_03_01.operations.Operations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,22 +49,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(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 @@ -73,7 +70,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 @@ -86,15 +83,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_metadata.json index 44776ee92548..b8b51e13257f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -100,4 +100,4 @@ "registries": "RegistriesOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_configuration.py index 7f2ac7f0a6f0..3b8eb2646d82 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-03-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", "2017-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_container_registry_management_client.py index 5579d058417e..3c3b0369c678 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -30,9 +30,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2017_03_01.aio.operations.RegistriesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.containerregistry.v2017_03_01.aio.operations.Operations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,22 +50,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(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 @@ -74,7 +71,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/__init__.py index 06aaf9c7fdb4..aacf7cb6c11d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._registries_operations import RegistriesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', + "RegistriesOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_operations.py index 58fdda32b2a0..4becaa8801ef 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_operations.py @@ -6,79 +6,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_03_01.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +115,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +132,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_registries_operations.py index 7383aef56257..40c8fd8b1d05 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_registries_operations.py @@ -6,201 +6,299 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_credentials_request, build_list_request, build_regenerate_credential_request, build_update_request -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_03_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, - registry_create_parameters: "_models.RegistryCreateParameters", + registry_create_parameters: Union[_models.RegistryCreateParameters, IO], **kwargs: Any - ) -> Optional["_models.Registry"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Registry"]] + ) -> Optional[_models.Registry]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_create_parameters, 'RegistryCreateParameters') + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Registry]] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_create_parameters, (IO, bytes)): + _content = registry_create_parameters + else: + _json = self._serialize.body(registry_create_parameters, "RegistryCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -209,34 +307,114 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry_create_parameters: _models.RegistryCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_create_parameters: The parameters for creating a container registry. Required. + :type registry_create_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_create_parameters: The parameters for creating a container registry. Required. + :type registry_create_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, registry_name: str, - registry_create_parameters: "_models.RegistryCreateParameters", + registry_create_parameters: Union[_models.RegistryCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_create_parameters: The parameters for creating a container registry. + :param registry_create_parameters: The parameters for creating a container registry. Is either + a model type or a IO type. Required. :type registry_create_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters 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 @@ -249,17 +427,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -267,76 +445,84 @@ async def begin_create( registry_create_parameters=registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -346,119 +532,206 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Registry: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters + :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: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Registry: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": + ) -> _models.Registry: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters 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: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -469,16 +742,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -488,49 +759,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -541,16 +824,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -560,135 +841,214 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/__init__.py index 92c134f35e8b..21fb7e7c2422 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/__init__.py @@ -23,31 +23,33 @@ from ._models_py3 import StorageAccountParameters from ._models_py3 import StorageAccountProperties - -from ._container_registry_management_client_enums import ( - PasswordName, - ProvisioningState, - SkuTier, -) +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import SkuTier +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryCreateParameters', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'Resource', - 'Sku', - 'StorageAccountParameters', - 'StorageAccountProperties', - 'PasswordName', - 'ProvisioningState', - 'SkuTier', + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "RegenerateCredentialParameters", + "Registry", + "RegistryCreateParameters", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "Resource", + "Sku", + "StorageAccountParameters", + "StorageAccountProperties", + "PasswordName", + "ProvisioningState", + "SkuTier", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_container_registry_management_client_enums.py index 2ddbaa20680c..2a227af999ea 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_container_registry_management_client_enums.py @@ -7,26 +7,24 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the container registry at the time the operation was called. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the container registry at the time the operation was called.""" CREATING = "Creating" SUCCEEDED = "Succeeded" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" BASIC = "Basic" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_models_py3.py index e97ee1fd8dfc..8943c7b254a2 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/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. @@ -6,14 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -23,16 +26,12 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, } def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, - **kwargs + self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplayDefinition"] = None, **kwargs ): """ :keyword name: Operation name: {provider}/{resource}/{operation}. @@ -40,12 +39,12 @@ def __init__( :keyword display: The display information for the container registry operation. :paramtype display: ~azure.mgmt.containerregistry.v2017_03_01.models.OperationDisplayDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -59,10 +58,10 @@ class OperationDisplayDefinition(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__( @@ -84,14 +83,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -103,16 +102,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -122,45 +117,40 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2017_03_01.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2017_03_01.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -173,43 +163,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -217,7 +201,7 @@ def __init__( self.tags = tags -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -230,19 +214,19 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2017_03_01.models.Sku :ivar login_server: The URL that can be used to log into the container registry. :vartype login_server: str :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Succeeded". + operation was called. Known values are: "Creating" and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2017_03_01.models.ProvisioningState :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. @@ -253,47 +237,47 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountProperties"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - admin_user_enabled: Optional[bool] = False, - storage_account: Optional["StorageAccountProperties"] = None, + admin_user_enabled: bool = False, + storage_account: Optional["_models.StorageAccountProperties"] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2017_03_01.models.Sku :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. :paramtype admin_user_enabled: bool @@ -301,7 +285,7 @@ def __init__( :paramtype storage_account: ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountProperties """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.login_server = None self.creation_date = None @@ -310,17 +294,17 @@ def __init__( self.storage_account = storage_account -class RegistryCreateParameters(msrest.serialization.Model): +class RegistryCreateParameters(_serialization.Model): """The parameters for creating a container registry. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] - :ivar location: Required. The location of the container registry. This cannot be changed after - the resource is created. + :ivar location: The location of the container registry. This cannot be changed after the + resource is created. Required. :vartype location: str - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2017_03_01.models.Sku :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. :vartype admin_user_enabled: bool @@ -331,35 +315,35 @@ class RegistryCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, - 'sku': {'required': True}, + "location": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountParameters'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountParameters"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - admin_user_enabled: Optional[bool] = False, - storage_account: Optional["StorageAccountParameters"] = None, + admin_user_enabled: bool = False, + storage_account: Optional["_models.StorageAccountParameters"] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the container registry. This cannot be changed - after the resource is created. + :keyword location: The location of the container registry. This cannot be changed after the + resource is created. Required. :paramtype location: str - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2017_03_01.models.Sku :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. :paramtype admin_user_enabled: bool @@ -368,7 +352,7 @@ def __init__( :paramtype storage_account: ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters """ - super(RegistryCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.sku = sku @@ -376,7 +360,7 @@ def __init__( self.storage_account = storage_account -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -386,16 +370,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -403,12 +383,12 @@ def __init__( :keyword passwords: The list of passwords for a container registry. :paramtype passwords: list[~azure.mgmt.containerregistry.v2017_03_01.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -419,17 +399,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -437,53 +411,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -496,9 +465,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -518,48 +487,44 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2017_03_01.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2017_03_01.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): """The parameters for updating a container registry. - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. :vartype admin_user_enabled: bool @@ -570,9 +535,9 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountParameters'}, + "tags": {"key": "tags", "type": "{str}"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountParameters"}, } def __init__( @@ -580,11 +545,11 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, admin_user_enabled: Optional[bool] = None, - storage_account: Optional["StorageAccountParameters"] = None, + storage_account: Optional["_models.StorageAccountParameters"] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. :paramtype admin_user_enabled: bool @@ -593,92 +558,81 @@ def __init__( :paramtype storage_account: ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.admin_user_enabled = admin_user_enabled self.storage_account = storage_account -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Allowed value: Basic. + :ivar name: The SKU name of the container registry. Required for registry creation. Allowed + value: Basic. Required. :vartype name: str - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Basic". + :ivar tier: The SKU tier based on the SKU name. "Basic" :vartype tier: str or ~azure.mgmt.containerregistry.v2017_03_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Allowed value: Basic. + :keyword name: The SKU name of the container registry. Required for registry creation. Allowed + value: Basic. Required. :paramtype name: str """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class StorageAccountParameters(msrest.serialization.Model): +class StorageAccountParameters(_serialization.Model): """The parameters of a storage account for a container registry. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the storage account. + :ivar name: The name of the storage account. Required. :vartype name: str - :ivar access_key: Required. The access key to the storage account. + :ivar access_key: The access key to the storage account. Required. :vartype access_key: str """ _validation = { - 'name': {'required': True}, - 'access_key': {'required': True}, + "name": {"required": True}, + "access_key": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "access_key": {"key": "accessKey", "type": "str"}, } - def __init__( - self, - *, - name: str, - access_key: str, - **kwargs - ): + def __init__(self, *, name: str, access_key: str, **kwargs): """ - :keyword name: Required. The name of the storage account. + :keyword name: The name of the storage account. Required. :paramtype name: str - :keyword access_key: Required. The access key to the storage account. + :keyword access_key: The access key to the storage account. Required. :paramtype access_key: str """ - super(StorageAccountParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.access_key = access_key -class StorageAccountProperties(msrest.serialization.Model): +class StorageAccountProperties(_serialization.Model): """The properties of a storage account for a container registry. :ivar name: The name of the storage account. @@ -686,18 +640,13 @@ class StorageAccountProperties(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of the storage account. :paramtype name: str """ - super(StorageAccountProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/__init__.py index 06aaf9c7fdb4..aacf7cb6c11d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._registries_operations import RegistriesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', + "RegistriesOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_operations.py index 56278e4c04e0..82784bee2e3b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_operations.py @@ -6,108 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - accept = "application/json" +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: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_03_01.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +137,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_registries_operations.py index fc46aac63f9c..14f06fb99162 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_registries_operations.py @@ -6,544 +6,573 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_03_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, - registry_create_parameters: "_models.RegistryCreateParameters", + registry_create_parameters: Union[_models.RegistryCreateParameters, IO], **kwargs: Any - ) -> Optional["_models.Registry"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Registry"]] + ) -> Optional[_models.Registry]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_create_parameters, 'RegistryCreateParameters') + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Registry]] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_create_parameters, (IO, bytes)): + _content = registry_create_parameters + else: + _json = self._serialize.body(registry_create_parameters, "RegistryCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -552,34 +581,112 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry_create_parameters: _models.RegistryCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_create_parameters: The parameters for creating a container registry. Required. + :type registry_create_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_create_parameters: The parameters for creating a container registry. Required. + :type registry_create_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, registry_name: str, - registry_create_parameters: "_models.RegistryCreateParameters", + registry_create_parameters: Union[_models.RegistryCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_create_parameters: The parameters for creating a container registry. + :param registry_create_parameters: The parameters for creating a container registry. Is either + a model type or a IO type. Required. :type registry_create_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters 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 @@ -591,17 +698,17 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -609,76 +716,84 @@ def begin_create( registry_create_parameters=registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -688,119 +803,205 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Registry: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters + :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: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Registry: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": + ) -> _models.Registry: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters 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: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -811,16 +1012,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,49 +1029,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_03_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -883,16 +1093,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -902,135 +1110,214 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_configuration.py index d1a166b6e2cd..8c851c1cf758 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-10-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", "2017-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_container_registry_management_client.py index 9d902f3f1436..277c72ad18fd 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -34,9 +34,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2017_10_01.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2017_10_01.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -54,10 +54,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -66,12 +68,7 @@ def __init__( self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -80,7 +77,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 @@ -93,15 +90,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_metadata.json index d27c9c2da3d9..d6f8f94c3416 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -102,4 +102,4 @@ "replications": "ReplicationsOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_configuration.py index 0aee57f2ea7c..f30773fc0507 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-10-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", "2017-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_container_registry_management_client.py index b50cba9a5905..b2ae89d79e36 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -35,9 +35,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2017_10_01.aio.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2017_10_01.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,10 +55,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -67,12 +69,7 @@ def __init__( self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -81,7 +78,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/__init__.py index 3c302d08d747..7a8d7099ae3f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_operations.py index da22917cad3c..22da6dc31ccb 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_operations.py @@ -6,79 +6,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +115,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +132,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_registries_operations.py index f37737abebcc..9f08955745c0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_registries_operations.py @@ -6,82 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_policies_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_policies_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_policies_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_policies_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,27 +132,103 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters 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 @@ -122,202 +239,279 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -325,36 +519,42 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry + :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 @@ -367,17 +567,86 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -385,63 +654,71 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -451,22 +728,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -478,80 +751,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -559,37 +852,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters 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 @@ -602,17 +975,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -620,76 +993,91 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -700,16 +1088,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -719,49 +1105,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -772,16 +1170,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -791,292 +1187,393 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace_async async def list_policies( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryPolicies": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryPolicies: """Lists the policies for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryPolicies, or the result of cls(response) + :return: RegistryPolicies or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryPolicies"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) - request = build_list_policies_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_policies.metadata['url'], + template_url=self.list_policies.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies"} # type: ignore - + list_policies.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies" + } async def _update_policies_initial( self, resource_group_name: str, registry_name: str, - registry_policies_update_parameters: "_models.RegistryPolicies", + registry_policies_update_parameters: Union[_models.RegistryPolicies, IO], **kwargs: Any - ) -> Optional["_models.RegistryPolicies"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RegistryPolicies"]] + ) -> Optional[_models.RegistryPolicies]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_policies_update_parameters, 'RegistryPolicies') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.RegistryPolicies]] = kwargs.pop("cls", None) - request = build_update_policies_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_policies_update_parameters, (IO, bytes)): + _content = registry_policies_update_parameters + else: + _json = self._serialize.body(registry_policies_update_parameters, "RegistryPolicies") + + request = build_update_policies_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_policies_initial.metadata['url'], + content=_content, + template_url=self._update_policies_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1085,35 +1582,116 @@ async def _update_policies_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_policies_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies"} # type: ignore + _update_policies_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies" + } + @overload + async def begin_update_policies( + self, + resource_group_name: str, + registry_name: str, + registry_policies_update_parameters: _models.RegistryPolicies, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RegistryPolicies]: + """Updates the policies for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_policies_update_parameters: The parameters for updating policies of a container + registry. Required. + :type registry_policies_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies + :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 RegistryPolicies or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_policies( + self, + resource_group_name: str, + registry_name: str, + registry_policies_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RegistryPolicies]: + """Updates the policies for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_policies_update_parameters: The parameters for updating policies of a container + registry. Required. + :type registry_policies_update_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 RegistryPolicies or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_policies( self, resource_group_name: str, registry_name: str, - registry_policies_update_parameters: "_models.RegistryPolicies", + registry_policies_update_parameters: Union[_models.RegistryPolicies, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.RegistryPolicies"]: + ) -> AsyncLROPoller[_models.RegistryPolicies]: """Updates the policies for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param registry_policies_update_parameters: The parameters for updating policies of a container - registry. + registry. Is either a model type or a IO type. Required. :type registry_policies_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies 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 @@ -1126,17 +1704,17 @@ async def begin_update_policies( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryPolicies"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_policies_initial( resource_group_name=resource_group_name, @@ -1144,29 +1722,34 @@ async def begin_update_policies( registry_policies_update_parameters=registry_policies_update_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 = pipeline_response.http_response - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies"} # type: ignore + begin_update_policies.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_replications_operations.py index ce6c8b968028..22a1798d70b9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_replications_operations.py @@ -6,147 +6,183 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +190,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +290,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication 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 @@ -199,17 +320,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -218,65 +339,72 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,25 +414,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -316,83 +441,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -400,18 +545,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -419,21 +646,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters 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 @@ -446,17 +677,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -465,82 +696,94 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +794,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +811,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_webhooks_operations.py index 960f20b7dbcc..a47a3cddd7a7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_webhooks_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +294,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters 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 @@ -200,17 +325,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +344,72 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +419,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -317,83 +446,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +550,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +651,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters 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 @@ -447,17 +682,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +701,94 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +799,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,191 +816,205 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -765,16 +1025,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -784,8 +1042,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/__init__.py index cd7984ba9fbd..033a0d2c5c6f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/__init__.py @@ -53,79 +53,81 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - DefaultAction, - ImportMode, - PasswordName, - PolicyStatus, - ProvisioningState, - RegistryUsageUnit, - SkuName, - SkuTier, - TrustPolicyType, - WebhookAction, - WebhookStatus, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Actor', - 'CallbackConfig', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'IPRule', - 'ImportImageParameters', - 'ImportSource', - 'ImportSourceCredentials', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryPolicies', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'Sku', - 'Source', - 'Status', - 'StorageAccountProperties', - 'Target', - 'TrustPolicy', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'DefaultAction', - 'ImportMode', - 'PasswordName', - 'PolicyStatus', - 'ProvisioningState', - 'RegistryUsageUnit', - 'SkuName', - 'SkuTier', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', + "Actor", + "CallbackConfig", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "IPRule", + "ImportImageParameters", + "ImportSource", + "ImportSourceCredentials", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryPolicies", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "Sku", + "Source", + "Status", + "StorageAccountProperties", + "Target", + "TrustPolicy", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "DefaultAction", + "ImportMode", + "PasswordName", + "PolicyStatus", + "ProvisioningState", + "RegistryUsageUnit", + "SkuName", + "SkuTier", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_container_registry_management_client_enums.py index 58c12bf3e36f..f795ea138eb9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_container_registry_management_client_enums.py @@ -7,24 +7,23 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -32,23 +31,23 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the container registry at the time the operation was called. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the container registry at the time the operation was called.""" CREATING = "Creating" UPDATING = "Updating" @@ -57,38 +56,40 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -96,9 +97,9 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_models_py3.py index 2833255b1ee3..ff97db7228bb 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -23,63 +26,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -87,20 +79,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -118,17 +105,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -141,12 +128,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2017_10_01.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -168,25 +155,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -207,7 +194,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2017_10_01.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -217,7 +204,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -228,17 +215,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -246,12 +227,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -267,17 +248,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -296,7 +277,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -304,7 +285,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -320,11 +301,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -349,7 +330,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -357,12 +338,12 @@ def __init__( self.version = version -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -371,33 +352,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2017_10_01.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -406,18 +387,18 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2017_10_01.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories self.mode = mode -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -428,22 +409,22 @@ class ImportSource(msrest.serialization.Model): :vartype registry_uri: str :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -452,7 +433,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -463,104 +444,92 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. :vartype virtual_network_rules: @@ -570,26 +539,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -598,13 +567,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2017_10_01.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -619,10 +588,13 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -630,8 +602,8 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -645,14 +617,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2017_10_01.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -666,10 +638,10 @@ class OperationDisplayDefinition(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__( @@ -691,14 +663,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -710,16 +682,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -729,12 +697,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -752,12 +720,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -785,7 +753,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -794,7 +762,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metrics list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -803,13 +771,13 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, **kwargs ): """ @@ -817,71 +785,61 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.containerregistry.v2017_10_01.models.OperationMetricSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """An object that represents quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -894,43 +852,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -938,7 +890,7 @@ def __init__( self.tags = tags -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -951,20 +903,20 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2017_10_01.models.Sku :ivar login_server: The URL that can be used to log into the container registry. :vartype login_server: str :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2017_10_01.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -980,51 +932,51 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountProperties"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - admin_user_enabled: Optional[bool] = False, - storage_account: Optional["StorageAccountProperties"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, + admin_user_enabled: bool = False, + storage_account: Optional["_models.StorageAccountProperties"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2017_10_01.models.Sku :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. :paramtype admin_user_enabled: bool @@ -1035,7 +987,7 @@ def __init__( :keyword network_rule_set: The network rule set for a container registry. :paramtype network_rule_set: ~azure.mgmt.containerregistry.v2017_10_01.models.NetworkRuleSet """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.login_server = None self.creation_date = None @@ -1046,7 +998,7 @@ def __init__( self.network_rule_set = network_rule_set -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -1056,16 +1008,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1073,12 +1021,12 @@ def __init__( :keyword passwords: The list of passwords for a container registry. :paramtype passwords: list[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -1089,17 +1037,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -1107,53 +1049,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -1166,9 +1103,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -1188,45 +1125,41 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryPolicies(msrest.serialization.Model): +class RegistryPolicies(_serialization.Model): """An object that represents policies for a container registry. :ivar quarantine_policy: An object that represents quarantine policy for a container registry. @@ -1236,15 +1169,15 @@ class RegistryPolicies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, **kwargs ): """ @@ -1254,15 +1187,15 @@ def __init__( :keyword trust_policy: An object that represents content trust policy for a container registry. :paramtype trust_policy: ~azure.mgmt.containerregistry.v2017_10_01.models.TrustPolicy """ - super(RegistryPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): """The parameters for updating a container registry. - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2017_10_01.models.Sku @@ -1278,25 +1211,25 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountProperties"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - storage_account: Optional["StorageAccountProperties"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, + storage_account: Optional["_models.StorageAccountProperties"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2017_10_01.models.Sku @@ -1310,7 +1243,7 @@ def __init__( :keyword network_rule_set: The network rule set for a container registry. :paramtype network_rule_set: ~azure.mgmt.containerregistry.v2017_10_01.models.NetworkRuleSet """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.sku = sku self.admin_user_enabled = admin_user_enabled @@ -1318,24 +1251,24 @@ def __init__( self.network_rule_set = network_rule_set -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -1344,27 +1277,27 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -1372,20 +1305,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -1402,13 +1330,13 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2017_10_01.models.ProvisioningState @@ -1417,44 +1345,38 @@ class Replication(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -1465,16 +1387,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -1483,37 +1401,32 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -1531,17 +1444,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -1562,7 +1475,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -1570,48 +1483,43 @@ def __init__( self.useragent = useragent -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2017_10_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2017_10_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -1622,17 +1530,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -1640,12 +1542,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -1659,71 +1561,62 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StorageAccountProperties(msrest.serialization.Model): +class StorageAccountProperties(_serialization.Model): """The properties of a storage account for a container registry. Only applicable to Classic SKU. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The resource ID of the storage account. + :ivar id: The resource ID of the storage account. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. The resource ID of the storage account. + :keyword id: The resource ID of the storage account. Required. :paramtype id: str """ - super(StorageAccountProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -1737,15 +1630,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1766,12 +1659,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -1783,7 +1676,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -1795,76 +1688,74 @@ def __init__( self.version = version -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """An object that represents content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2017_10_01.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = None, - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Optional[Union[str, "_models.TrustPolicyType"]] = None, + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2017_10_01.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2017_10_01.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -1882,13 +1773,13 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -1897,30 +1788,30 @@ class Webhook(Resource): :ivar actions: The list of actions that trigger the webhook to post notifications. :vartype actions: list[str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2017_10_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1928,19 +1819,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -1949,29 +1840,29 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -1982,17 +1873,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -2002,23 +1893,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2027,7 +1918,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -2037,7 +1928,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -2048,17 +1939,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -2066,22 +1951,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -2092,12 +1977,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -2106,20 +1991,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2128,7 +2013,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/__init__.py index 3c302d08d747..7a8d7099ae3f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_operations.py index 43c47f307332..ce7b77d3663b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_operations.py @@ -6,108 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - accept = "application/json" +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: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +137,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_registries_operations.py index 15dddcf05047..1ddaef288836 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_registries_operations.py @@ -6,583 +6,528 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_policies_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_policies_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_policies_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -592,27 +537,103 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters 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 @@ -623,202 +644,279 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -826,36 +924,42 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry + :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 @@ -867,17 +971,84 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -885,63 +1056,71 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -951,22 +1130,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -978,80 +1153,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1059,37 +1254,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters 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 @@ -1101,17 +1374,17 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1119,76 +1392,90 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1199,16 +1486,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1218,49 +1503,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1271,16 +1567,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1290,292 +1584,391 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace - def list_policies( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryPolicies": + def list_policies(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.RegistryPolicies: """Lists the policies for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryPolicies, or the result of cls(response) + :return: RegistryPolicies or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryPolicies"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) - request = build_list_policies_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_policies.metadata['url'], + template_url=self.list_policies.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies"} # type: ignore - + list_policies.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies" + } def _update_policies_initial( self, resource_group_name: str, registry_name: str, - registry_policies_update_parameters: "_models.RegistryPolicies", + registry_policies_update_parameters: Union[_models.RegistryPolicies, IO], **kwargs: Any - ) -> Optional["_models.RegistryPolicies"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RegistryPolicies"]] + ) -> Optional[_models.RegistryPolicies]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_policies_update_parameters, 'RegistryPolicies') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.RegistryPolicies]] = kwargs.pop("cls", None) - request = build_update_policies_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_policies_update_parameters, (IO, bytes)): + _content = registry_policies_update_parameters + else: + _json = self._serialize.body(registry_policies_update_parameters, "RegistryPolicies") + + request = build_update_policies_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_policies_initial.metadata['url'], + content=_content, + template_url=self._update_policies_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1584,35 +1977,116 @@ def _update_policies_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_policies_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies"} # type: ignore + _update_policies_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies" + } + + @overload + def begin_update_policies( + self, + resource_group_name: str, + registry_name: str, + registry_policies_update_parameters: _models.RegistryPolicies, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RegistryPolicies]: + """Updates the policies for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_policies_update_parameters: The parameters for updating policies of a container + registry. Required. + :type registry_policies_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies + :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 RegistryPolicies or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_policies( + self, + resource_group_name: str, + registry_name: str, + registry_policies_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RegistryPolicies]: + """Updates the policies for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_policies_update_parameters: The parameters for updating policies of a container + registry. Required. + :type registry_policies_update_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 RegistryPolicies or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_policies( self, resource_group_name: str, registry_name: str, - registry_policies_update_parameters: "_models.RegistryPolicies", + registry_policies_update_parameters: Union[_models.RegistryPolicies, IO], **kwargs: Any - ) -> LROPoller["_models.RegistryPolicies"]: + ) -> LROPoller[_models.RegistryPolicies]: """Updates the policies for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param registry_policies_update_parameters: The parameters for updating policies of a container - registry. + registry. Is either a model type or a IO type. Required. :type registry_policies_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies + ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies 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 @@ -1625,17 +2099,17 @@ def begin_update_policies( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryPolicies"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_policies_initial( resource_group_name=resource_group_name, @@ -1643,29 +2117,34 @@ def begin_update_policies( registry_policies_update_parameters=registry_policies_update_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 = pipeline_response.http_response - deserialized = self._deserialize('RegistryPolicies', pipeline_response) + deserialized = self._deserialize("RegistryPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies"} # type: ignore + begin_update_policies.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_replications_operations.py index 1ab5ad01504d..2e38059e2a8b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_replications_operations.py @@ -6,348 +6,356 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_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, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ReplicationsOperations(object): - """ReplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +363,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +463,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication 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 @@ -400,17 +493,17 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +512,72 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +587,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -517,83 +614,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +718,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +819,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters 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 @@ -647,17 +850,17 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -666,82 +869,94 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -752,16 +967,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -771,8 +984,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_webhooks_operations.py index b316567296cb..0faa9fc0dbab 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_webhooks_operations.py @@ -6,462 +6,462 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_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, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WebhooksOperations(object): - """WebhooksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2017_10_01.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -469,18 +469,96 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -488,21 +566,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters 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 @@ -513,17 +595,17 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -532,65 +614,72 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -600,25 +689,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -630,83 +716,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -714,18 +820,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -733,21 +917,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters 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 @@ -758,17 +946,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -777,81 +965,93 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -862,16 +1062,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -881,191 +1079,202 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-10-01") # type: str + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2017_10_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2017-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1076,16 +1285,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1095,8 +1302,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_configuration.py index bdab822f19f7..aed86ecd8e8b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + api_version: Literal["2018-02-01-preview"] = kwargs.pop("api_version", "2018-02-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_container_registry_management_client.py index 597cbc01f632..9169855c0277 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import BuildStepsOperations, BuildTasksOperations, BuildsOperations, RegistriesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar builds: BuildsOperations operations @@ -36,9 +36,9 @@ class ContainerRegistryManagementClient: :ivar registries: RegistriesOperations operations :vartype registries: azure.mgmt.containerregistry.v2018_02_01_preview.operations.RegistriesOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -56,10 +56,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -68,12 +70,7 @@ def __init__( self.build_tasks = BuildTasksOperations(self._client, self._config, self._serialize, self._deserialize) self.registries = RegistriesOperations(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 @@ -82,7 +79,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 @@ -95,15 +92,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_metadata.json index b0a56355ff00..c0efc843e0a1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -102,4 +102,4 @@ "build_tasks": "BuildTasksOperations", "registries": "RegistriesOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_configuration.py index 603c5dbfa925..aa46840a0d75 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + api_version: Literal["2018-02-01-preview"] = kwargs.pop("api_version", "2018-02-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_container_registry_management_client.py index 21b4468df5f8..3953fa198048 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import BuildStepsOperations, BuildTasksOperations, BuildsOperations, RegistriesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar builds: BuildsOperations operations @@ -37,9 +37,9 @@ class ContainerRegistryManagementClient: :ivar registries: RegistriesOperations operations :vartype registries: azure.mgmt.containerregistry.v2018_02_01_preview.aio.operations.RegistriesOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,10 +57,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -69,12 +71,7 @@ def __init__( self.build_tasks = BuildTasksOperations(self._client, self._config, self._serialize, self._deserialize) self.registries = RegistriesOperations(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 @@ -83,7 +80,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/__init__.py index 3f9b755bf5d2..cf2f497714be 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._build_tasks_operations import BuildTasksOperations from ._registries_operations import RegistriesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'BuildsOperations', - 'BuildStepsOperations', - 'BuildTasksOperations', - 'RegistriesOperations', + "BuildsOperations", + "BuildStepsOperations", + "BuildTasksOperations", + "RegistriesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_steps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_steps_operations.py index 78af70ce93b4..5a1ad2bf2c00 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_steps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_steps_operations.py @@ -6,100 +6,130 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_steps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_build_arguments_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._build_steps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_build_arguments_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildStepsOperations: - """BuildStepsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BuildStepsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`build_steps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildStepList"]: + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildStep"]: """List all the build steps for a given build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildStepList or the result of cls(response) + :return: An iterator like instance of either BuildStep or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildStepList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStepList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - build_task_name=build_task_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -110,16 +140,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BuildStepList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -129,78 +157,82 @@ 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.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any - ) -> "_models.BuildStep": + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any + ) -> _models.BuildStep: """Gets the build step for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildStep, or the result of cls(response) + :return: BuildStep or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } async def _create_initial( self, @@ -208,39 +240,55 @@ async def _create_initial( registry_name: str, build_task_name: str, step_name: str, - build_step_create_parameters: "_models.BuildStep", + build_step_create_parameters: Union[_models.BuildStep, IO], **kwargs: Any - ) -> "_models.BuildStep": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] + ) -> _models.BuildStep: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_step_create_parameters, 'BuildStep') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_step_create_parameters, (IO, bytes)): + _content = build_step_create_parameters + else: + _json = self._serialize.body(build_step_create_parameters, "BuildStep") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -248,18 +296,106 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_create_parameters: _models.BuildStep, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildStep]: + """Creates a build step for a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_create_parameters: The parameters for creating a build step. Required. + :type build_step_create_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep + :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 BuildStep or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildStep]: + """Creates a build step for a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_create_parameters: The parameters for creating a build step. Required. + :type build_step_create_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 BuildStep or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -268,23 +404,27 @@ async def begin_create( registry_name: str, build_task_name: str, step_name: str, - build_step_create_parameters: "_models.BuildStep", + build_step_create_parameters: Union[_models.BuildStep, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildStep"]: + ) -> AsyncLROPoller[_models.BuildStep]: """Creates a build step for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str - :param build_step_create_parameters: The parameters for creating a build step. + :param build_step_create_parameters: The parameters for creating a build step. Is either a + model type or a IO type. Required. :type build_step_create_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep 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 @@ -297,17 +437,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -317,67 +459,75 @@ async def begin_create( build_step_create_parameters=build_step_create_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -387,28 +537,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a build step from the build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_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. @@ -420,46 +566,54 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } async def _update_initial( self, @@ -467,39 +621,55 @@ async def _update_initial( registry_name: str, build_task_name: str, step_name: str, - build_step_update_parameters: "_models.BuildStepUpdateParameters", + build_step_update_parameters: Union[_models.BuildStepUpdateParameters, IO], **kwargs: Any - ) -> "_models.BuildStep": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] + ) -> _models.BuildStep: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_step_update_parameters, 'BuildStepUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_step_update_parameters, (IO, bytes)): + _content = build_step_update_parameters + else: + _json = self._serialize.body(build_step_update_parameters, "BuildStepUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -507,18 +677,106 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_update_parameters: _models.BuildStepUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildStep]: + """Updates a build step in a build task. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_update_parameters: The parameters for updating a build step. Required. + :type build_step_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters + :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 BuildStep or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildStep]: + """Updates a build step in a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_update_parameters: The parameters for updating a build step. Required. + :type build_step_update_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 BuildStep or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -527,23 +785,27 @@ async def begin_update( registry_name: str, build_task_name: str, step_name: str, - build_step_update_parameters: "_models.BuildStepUpdateParameters", + build_step_update_parameters: Union[_models.BuildStepUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildStep"]: + ) -> AsyncLROPoller[_models.BuildStep]: """Updates a build step in a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str - :param build_step_update_parameters: The parameters for updating a build step. + :param build_step_update_parameters: The parameters for updating a build step. Is either a + model type or a IO type. Required. :type build_step_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters 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 @@ -556,17 +818,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -576,91 +840,104 @@ async def begin_update( build_step_update_parameters=build_step_update_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } @distributed_trace def list_build_arguments( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BuildArgumentList"]: + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BuildArgument"]: """List the build arguments for a step including the secret arguments. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildArgumentList or the result of cls(response) + :return: An iterator like instance of either BuildArgument or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgumentList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgument] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildArgumentList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildArgumentList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_arguments_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_arguments.metadata['url'], + template_url=self.list_build_arguments.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_build_arguments_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - build_task_name=build_task_name, - step_name=step_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -671,16 +948,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BuildArgumentList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -690,8 +965,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_build_arguments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments"} # type: ignore + list_build_arguments.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_tasks_operations.py index 4cb757a65cf6..88bb60ade881 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_build_tasks_operations.py @@ -6,46 +6,66 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._build_tasks_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_list_source_repository_properties_request, build_update_request_initial -T = TypeVar('T') +from ...operations._build_tasks_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_list_source_repository_properties_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildTasksOperations: - """BuildTasksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BuildTasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`build_tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -55,13 +75,13 @@ def list( filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.BuildTaskListResult"]: + ) -> AsyncIterable["_models.BuildTask"]: """Lists all the build tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The build task filter to apply on the operation. Default value is None. :type filter: str @@ -69,43 +89,56 @@ def list( page in the list of tasks. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildTaskListResult or the result of cls(response) + :return: An iterator like instance of either BuildTask or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildTaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, skip_token=skip_token, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - skip_token=skip_token, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -116,16 +149,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BuildTaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,112 +166,133 @@ 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.ContainerRegistry/registries/{registryName}/buildTasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> "_models.BuildTask": + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> _models.BuildTask: """Get the properties of a specified build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildTask, or the result of cls(response) + :return: BuildTask or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01-preview") # type: str + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, build_task_name: str, - build_task_create_parameters: "_models.BuildTask", + build_task_create_parameters: Union[_models.BuildTask, IO], **kwargs: Any - ) -> "_models.BuildTask": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] + ) -> _models.BuildTask: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_task_create_parameters, 'BuildTask') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_task_create_parameters, (IO, bytes)): + _content = build_task_create_parameters + else: + _json = self._serialize.body(build_task_create_parameters, "BuildTask") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -248,18 +300,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_create_parameters: _models.BuildTask, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildTask]: + """Creates a build task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_create_parameters: The parameters for creating a build task. Required. + :type build_task_create_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask + :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 BuildTask or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildTask]: + """Creates a build task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_create_parameters: The parameters for creating a build task. Required. + :type build_task_create_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 BuildTask or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -267,21 +401,25 @@ async def begin_create( resource_group_name: str, registry_name: str, build_task_name: str, - build_task_create_parameters: "_models.BuildTask", + build_task_create_parameters: Union[_models.BuildTask, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildTask"]: + ) -> AsyncLROPoller[_models.BuildTask]: """Creates a build task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param build_task_create_parameters: The parameters for creating a build task. + :param build_task_create_parameters: The parameters for creating a build task. Is either a + model type or a IO type. Required. :type build_task_create_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask 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 @@ -294,17 +432,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -313,65 +453,74 @@ async def begin_create( build_task_create_parameters=build_task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -381,25 +530,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_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. @@ -411,83 +557,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, build_task_name: str, - build_task_update_parameters: "_models.BuildTaskUpdateParameters", + build_task_update_parameters: Union[_models.BuildTaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.BuildTask": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] + ) -> _models.BuildTask: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_task_update_parameters, 'BuildTaskUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_task_update_parameters, (IO, bytes)): + _content = build_task_update_parameters + else: + _json = self._serialize.body(build_task_update_parameters, "BuildTaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -495,18 +665,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_update_parameters: _models.BuildTaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildTask]: + """Updates a build task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_update_parameters: The parameters for updating a build task. Required. + :type build_task_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters + :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 BuildTask or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BuildTask]: + """Updates a build task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_update_parameters: The parameters for updating a build task. Required. + :type build_task_update_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 BuildTask or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -514,21 +766,25 @@ async def begin_update( resource_group_name: str, registry_name: str, build_task_name: str, - build_task_update_parameters: "_models.BuildTaskUpdateParameters", + build_task_update_parameters: Union[_models.BuildTaskUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.BuildTask"]: + ) -> AsyncLROPoller[_models.BuildTask]: """Updates a build task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param build_task_update_parameters: The parameters for updating a build task. + :param build_task_update_parameters: The parameters for updating a build task. Is either a + model type or a IO type. Required. :type build_task_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters 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 @@ -541,17 +797,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -560,92 +818,102 @@ async def begin_update( build_task_update_parameters=build_task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } @distributed_trace_async async def list_source_repository_properties( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> "_models.SourceRepositoryProperties": + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> _models.SourceRepositoryProperties: """Get the source control properties for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceRepositoryProperties, or the result of cls(response) + :return: SourceRepositoryProperties or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceRepositoryProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceRepositoryProperties"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.SourceRepositoryProperties] = kwargs.pop("cls", None) - request = build_list_source_repository_properties_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_source_repository_properties.metadata['url'], + template_url=self.list_source_repository_properties.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceRepositoryProperties', pipeline_response) + deserialized = self._deserialize("SourceRepositoryProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_source_repository_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties"} # type: ignore - + list_source_repository_properties.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_builds_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_builds_operations.py index f9c7729246d4..f5ef3cb0e176 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_builds_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_builds_operations.py @@ -6,46 +6,65 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._builds_operations import build_cancel_request_initial, build_get_log_link_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._builds_operations import ( + build_cancel_request, + build_get_log_link_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BuildsOperations: - """BuildsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BuildsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`builds` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -56,13 +75,13 @@ def list( top: Optional[int] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.BuildListResult"]: + ) -> AsyncIterable["_models.Build"]: """Gets all the builds for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The builds filter to apply on the operation. Default value is None. :type filter: str @@ -73,45 +92,57 @@ def list( in the list of builds. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildListResult or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, skip_token=skip_token, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - skip_token=skip_token, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -122,16 +153,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("BuildListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,112 +170,131 @@ 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.ContainerRegistry/registries/{registryName}/builds"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any - ) -> "_models.Build": + async def get(self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any) -> _models.Build: """Gets the detailed information for a given build. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01-preview") # type: str + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, build_id: str, - build_update_parameters: "_models.BuildUpdateParameters", + build_update_parameters: Union[_models.BuildUpdateParameters, IO], **kwargs: Any - ) -> "_models.Build": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] + ) -> _models.Build: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_update_parameters, 'BuildUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_update_parameters, (IO, bytes)): + _content = build_update_parameters + else: + _json = self._serialize.body(build_update_parameters, "BuildUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -254,18 +302,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_id: str, + build_update_parameters: _models.BuildUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Build]: + """Patch the build properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_id: The build ID. Required. + :type build_id: str + :param build_update_parameters: The build update properties. Required. + :type build_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters + :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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_id: str, + build_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Build]: + """Patch the build properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_id: The build ID. Required. + :type build_id: str + :param build_update_parameters: The build update properties. Required. + :type build_update_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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -273,21 +401,25 @@ async def begin_update( resource_group_name: str, registry_name: str, build_id: str, - build_update_parameters: "_models.BuildUpdateParameters", + build_update_parameters: Union[_models.BuildUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Build"]: + ) -> AsyncLROPoller[_models.Build]: """Patch the build properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str - :param build_update_parameters: The build update properties. + :param build_update_parameters: The build update properties. Is either a model type or a IO + type. Required. :type build_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters 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 @@ -299,17 +431,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Build or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -318,128 +452,142 @@ async def begin_update( build_update_parameters=build_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } @distributed_trace_async async def get_log_link( - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any - ) -> "_models.BuildGetLogResult": + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any + ) -> _models.BuildGetLogResult: """Gets a link to download the build logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildGetLogResult, or the result of cls(response) + :return: BuildGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_link_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_link.metadata['url'], + template_url=self.get_log_link.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildGetLogResult', pipeline_response) + deserialized = self._deserialize("BuildGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_link.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink"} # type: ignore - + get_log_link.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink" + } async def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -449,25 +597,22 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel" + } @distributed_trace_async - async def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + async def begin_cancel( + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Cancel an existing build. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: 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. @@ -479,42 +624,50 @@ async def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_registries_operations.py index 153025a6dbf0..3f88550e2b57 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/aio/operations/_registries_operations.py @@ -6,80 +6,108 @@ # 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, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_get_build_source_upload_url_request, build_queue_build_request_initial -T = TypeVar('T') +from ...operations._registries_operations import build_get_build_source_upload_url_request, build_queue_build_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _queue_build_initial( self, resource_group_name: str, registry_name: str, - build_request: "_models.QueueBuildRequest", + build_request: Union[_models.QueueBuildRequest, IO], **kwargs: Any - ) -> Optional["_models.Build"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Build"]] + ) -> Optional[_models.Build]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(build_request, 'QueueBuildRequest') - - request = build_queue_build_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Build]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_request, (IO, bytes)): + _content = build_request + else: + _json = self._serialize.body(build_request, "QueueBuildRequest") + + request = build_queue_build_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._queue_build_initial.metadata['url'], + content=_content, + template_url=self._queue_build_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -88,33 +116,111 @@ async def _queue_build_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _queue_build_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild"} # type: ignore + _queue_build_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild" + } + + @overload + async def begin_queue_build( + self, + resource_group_name: str, + registry_name: str, + build_request: _models.QueueBuildRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Build]: + """Creates a new build based on the request parameters and add it to the build queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_request: The parameters of a build that needs to queued. Required. + :type build_request: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.QueueBuildRequest + :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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_queue_build( + self, + resource_group_name: str, + registry_name: str, + build_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Build]: + """Creates a new build based on the request parameters and add it to the build queue. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_request: The parameters of a build that needs to queued. Required. + :type build_request: 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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_queue_build( self, resource_group_name: str, registry_name: str, - build_request: "_models.QueueBuildRequest", + build_request: Union[_models.QueueBuildRequest, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Build"]: + ) -> AsyncLROPoller[_models.Build]: """Creates a new build based on the request parameters and add it to the build queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_request: The parameters of a build that needs to queued. + :param build_request: The parameters of a build that needs to queued. Is either a model type or + a IO type. Required. :type build_request: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.QueueBuildRequest + 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 @@ -126,17 +232,19 @@ async def begin_queue_build( :return: An instance of AsyncLROPoller that returns either Build or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._queue_build_initial( resource_group_name=resource_group_name, @@ -144,88 +252,99 @@ async def begin_queue_build( build_request=build_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_queue_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild"} # type: ignore + begin_queue_build.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild" + } @distributed_trace_async async def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/__init__.py index 7d20d2b67372..d4019b3b1152 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/__init__.py @@ -39,63 +39,65 @@ from ._models_py3 import SourceRepositoryUpdateParameters from ._models_py3 import SourceUploadDefinition - -from ._container_registry_management_client_enums import ( - BaseImageDependencyType, - BaseImageTriggerType, - BuildArgumentType, - BuildStatus, - BuildStepType, - BuildTaskStatus, - BuildType, - OsType, - ProvisioningState, - SourceControlType, - TokenType, -) +from ._container_registry_management_client_enums import BaseImageDependencyType +from ._container_registry_management_client_enums import BaseImageTriggerType +from ._container_registry_management_client_enums import BuildArgumentType +from ._container_registry_management_client_enums import BuildStatus +from ._container_registry_management_client_enums import BuildStepType +from ._container_registry_management_client_enums import BuildTaskStatus +from ._container_registry_management_client_enums import BuildType +from ._container_registry_management_client_enums import OsType +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import SourceControlType +from ._container_registry_management_client_enums import TokenType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'BaseImageDependency', - 'Build', - 'BuildArgument', - 'BuildArgumentList', - 'BuildFilter', - 'BuildGetLogResult', - 'BuildListResult', - 'BuildStep', - 'BuildStepList', - 'BuildStepProperties', - 'BuildStepPropertiesUpdateParameters', - 'BuildStepUpdateParameters', - 'BuildTask', - 'BuildTaskBuildRequest', - 'BuildTaskFilter', - 'BuildTaskListResult', - 'BuildTaskUpdateParameters', - 'BuildUpdateParameters', - 'DockerBuildStep', - 'DockerBuildStepUpdateParameters', - 'GitCommitTrigger', - 'ImageDescriptor', - 'ImageUpdateTrigger', - 'PlatformProperties', - 'ProxyResource', - 'QueueBuildRequest', - 'QuickBuildRequest', - 'Resource', - 'SourceControlAuthInfo', - 'SourceRepositoryProperties', - 'SourceRepositoryUpdateParameters', - 'SourceUploadDefinition', - 'BaseImageDependencyType', - 'BaseImageTriggerType', - 'BuildArgumentType', - 'BuildStatus', - 'BuildStepType', - 'BuildTaskStatus', - 'BuildType', - 'OsType', - 'ProvisioningState', - 'SourceControlType', - 'TokenType', + "BaseImageDependency", + "Build", + "BuildArgument", + "BuildArgumentList", + "BuildFilter", + "BuildGetLogResult", + "BuildListResult", + "BuildStep", + "BuildStepList", + "BuildStepProperties", + "BuildStepPropertiesUpdateParameters", + "BuildStepUpdateParameters", + "BuildTask", + "BuildTaskBuildRequest", + "BuildTaskFilter", + "BuildTaskListResult", + "BuildTaskUpdateParameters", + "BuildUpdateParameters", + "DockerBuildStep", + "DockerBuildStepUpdateParameters", + "GitCommitTrigger", + "ImageDescriptor", + "ImageUpdateTrigger", + "PlatformProperties", + "ProxyResource", + "QueueBuildRequest", + "QuickBuildRequest", + "Resource", + "SourceControlAuthInfo", + "SourceRepositoryProperties", + "SourceRepositoryUpdateParameters", + "SourceUploadDefinition", + "BaseImageDependencyType", + "BaseImageTriggerType", + "BuildArgumentType", + "BuildStatus", + "BuildStepType", + "BuildTaskStatus", + "BuildType", + "OsType", + "ProvisioningState", + "SourceControlType", + "TokenType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_container_registry_management_client_enums.py index 9499ac62cc76..8578ee70d5bc 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_container_registry_management_client_enums.py @@ -7,34 +7,32 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class BaseImageDependencyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the base image dependency. - """ +class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the base image dependency.""" BUILD_TIME = "BuildTime" RUN_TIME = "RunTime" -class BaseImageTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the auto trigger for base image dependency updates. - """ + +class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the auto trigger for base image dependency updates.""" ALL = "All" RUNTIME = "Runtime" NONE = "None" -class BuildArgumentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the argument. - """ + +class BuildArgumentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the argument.""" DOCKER_BUILD_ARGUMENT = "DockerBuildArgument" -class BuildStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the build. - """ + +class BuildStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the build.""" QUEUED = "Queued" STARTED = "Started" @@ -45,36 +43,36 @@ class BuildStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" TIMEOUT = "Timeout" -class BuildStepType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the step. - """ + +class BuildStepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the step.""" DOCKER = "Docker" -class BuildTaskStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of build task. - """ + +class BuildTaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of build task.""" DISABLED = "Disabled" ENABLED = "Enabled" -class BuildType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of build. - """ + +class BuildType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of build.""" AUTO_BUILD = "AutoBuild" QUICK_BUILD = "QuickBuild" -class OsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operating system type required for the build. - """ + +class OsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type required for the build.""" WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of a build. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a build.""" CREATING = "Creating" UPDATING = "Updating" @@ -83,16 +81,16 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class SourceControlType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source control service. - """ + +class SourceControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source control service.""" GITHUB = "Github" VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" -class TokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of Auth token. - """ + +class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of Auth token.""" PAT = "PAT" O_AUTH = "OAuth" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_models_py3.py index 358493b1c917..9a9deceedce3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/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. @@ -7,18 +8,19 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class BaseImageDependency(msrest.serialization.Model): +class BaseImageDependency(_serialization.Model): """Properties that describe a base image dependency. - :ivar type: The type of the base image dependency. Possible values include: "BuildTime", - "RunTime". + :ivar type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageDependencyType :ivar registry: The registry login server. @@ -32,17 +34,17 @@ class BaseImageDependency(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "BaseImageDependencyType"]] = None, + type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, registry: Optional[str] = None, repository: Optional[str] = None, tag: Optional[str] = None, @@ -50,7 +52,7 @@ def __init__( **kwargs ): """ - :keyword type: The type of the base image dependency. Possible values include: "BuildTime", + :keyword type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :paramtype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageDependencyType @@ -63,7 +65,7 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(BaseImageDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.registry = registry self.repository = repository @@ -71,7 +73,7 @@ def __init__( self.digest = digest -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -85,30 +87,26 @@ class ProxyResource(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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class Build(ProxyResource): +class Build(ProxyResource): # pylint: disable=too-many-instance-attributes """Build resource properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,12 +119,12 @@ class Build(ProxyResource): :vartype type: str :ivar build_id: The unique identifier for the build. :vartype build_id: str - :ivar status: The current status of the build. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the build. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStatus :ivar last_updated_time: The last updated time for the build. :vartype last_updated_time: ~datetime.datetime - :ivar build_type: The type of build. Possible values include: "AutoBuild", "QuickBuild". + :ivar build_type: The type of build. Known values are: "AutoBuild" and "QuickBuild". :vartype build_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildType :ivar create_time: The time the build was created. :vartype create_time: ~datetime.datetime @@ -149,66 +147,66 @@ class Build(ProxyResource): :vartype is_archive_enabled: bool :ivar platform: The platform properties against which the build will happen. :vartype platform: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.PlatformProperties - :ivar provisioning_state: The provisioning state of a build. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a build. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.ProvisioningState """ _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'}, - 'build_id': {'key': 'properties.buildId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'build_type': {'key': 'properties.buildType', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'properties.finishTime', 'type': 'iso-8601'}, - 'output_images': {'key': 'properties.outputImages', 'type': '[ImageDescriptor]'}, - 'build_task': {'key': 'properties.buildTask', 'type': 'str'}, - 'image_update_trigger': {'key': 'properties.imageUpdateTrigger', 'type': 'ImageUpdateTrigger'}, - 'git_commit_trigger': {'key': 'properties.gitCommitTrigger', 'type': 'GitCommitTrigger'}, - 'is_archive_enabled': {'key': 'properties.isArchiveEnabled', 'type': 'bool'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "build_id": {"key": "properties.buildId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "build_type": {"key": "properties.buildType", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "finish_time": {"key": "properties.finishTime", "type": "iso-8601"}, + "output_images": {"key": "properties.outputImages", "type": "[ImageDescriptor]"}, + "build_task": {"key": "properties.buildTask", "type": "str"}, + "image_update_trigger": {"key": "properties.imageUpdateTrigger", "type": "ImageUpdateTrigger"}, + "git_commit_trigger": {"key": "properties.gitCommitTrigger", "type": "GitCommitTrigger"}, + "is_archive_enabled": {"key": "properties.isArchiveEnabled", "type": "bool"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, build_id: Optional[str] = None, - status: Optional[Union[str, "BuildStatus"]] = None, + status: Optional[Union[str, "_models.BuildStatus"]] = None, last_updated_time: Optional[datetime.datetime] = None, - build_type: Optional[Union[str, "BuildType"]] = None, + build_type: Optional[Union[str, "_models.BuildType"]] = None, create_time: Optional[datetime.datetime] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - output_images: Optional[List["ImageDescriptor"]] = None, + output_images: Optional[List["_models.ImageDescriptor"]] = None, build_task: Optional[str] = None, - image_update_trigger: Optional["ImageUpdateTrigger"] = None, - git_commit_trigger: Optional["GitCommitTrigger"] = None, - is_archive_enabled: Optional[bool] = False, - platform: Optional["PlatformProperties"] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + image_update_trigger: Optional["_models.ImageUpdateTrigger"] = None, + git_commit_trigger: Optional["_models.GitCommitTrigger"] = None, + is_archive_enabled: bool = False, + platform: Optional["_models.PlatformProperties"] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, **kwargs ): """ :keyword build_id: The unique identifier for the build. :paramtype build_id: str - :keyword status: The current status of the build. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the build. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStatus :keyword last_updated_time: The last updated time for the build. :paramtype last_updated_time: ~datetime.datetime - :keyword build_type: The type of build. Possible values include: "AutoBuild", "QuickBuild". + :keyword build_type: The type of build. Known values are: "AutoBuild" and "QuickBuild". :paramtype build_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildType :keyword create_time: The time the build was created. @@ -233,12 +231,12 @@ def __init__( :keyword platform: The platform properties against which the build will happen. :paramtype platform: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.PlatformProperties - :keyword provisioning_state: The provisioning state of a build. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :keyword provisioning_state: The provisioning state of a build. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :paramtype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.ProvisioningState """ - super(Build, self).__init__(**kwargs) + super().__init__(**kwargs) self.build_id = build_id self.status = status self.last_updated_time = last_updated_time @@ -255,17 +253,17 @@ def __init__( self.provisioning_state = provisioning_state -class BuildArgument(msrest.serialization.Model): +class BuildArgument(_serialization.Model): """Properties of a build argument. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the argument. Possible values include: "DockerBuildArgument". + :ivar type: The type of the argument. Required. "DockerBuildArgument" :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgumentType - :ivar name: Required. The name of the argument. + :ivar name: The name of the argument. Required. :vartype name: str - :ivar value: Required. The value of the argument. + :ivar value: The value of the argument. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. @@ -273,48 +271,41 @@ class BuildArgument(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, - 'value': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } def __init__( - self, - *, - type: Union[str, "BuildArgumentType"], - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs + self, *, type: Union[str, "_models.BuildArgumentType"], name: str, value: str, is_secret: bool = False, **kwargs ): """ - :keyword type: Required. The type of the argument. Possible values include: - "DockerBuildArgument". + :keyword type: The type of the argument. Required. "DockerBuildArgument" :paramtype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgumentType - :keyword name: Required. The name of the argument. + :keyword name: The name of the argument. Required. :paramtype name: str - :keyword value: Required. The value of the argument. + :keyword value: The value of the argument. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. :paramtype is_secret: bool """ - super(BuildArgument, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name self.value = value self.is_secret = is_secret -class BuildArgumentList(msrest.serialization.Model): +class BuildArgumentList(_serialization.Model): """The list of build arguments for a build step. :ivar value: The collection value. @@ -324,16 +315,12 @@ class BuildArgumentList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildArgument]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildArgument]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["BuildArgument"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.BuildArgument"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The collection value. @@ -341,20 +328,20 @@ def __init__( :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(BuildArgumentList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildFilter(msrest.serialization.Model): +class BuildFilter(_serialization.Model): """Properties that are enabled for Odata querying. :ivar build_id: The unique identifier for the build. :vartype build_id: str - :ivar build_type: The type of build. Possible values include: "AutoBuild", "QuickBuild". + :ivar build_type: The type of build. Known values are: "AutoBuild" and "QuickBuild". :vartype build_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildType - :ivar status: The current status of the build. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the build. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStatus :ivar create_time: The create time for a build. :vartype create_time: ~datetime.datetime @@ -370,22 +357,22 @@ class BuildFilter(msrest.serialization.Model): """ _attribute_map = { - 'build_id': {'key': 'buildId', 'type': 'str'}, - 'build_type': {'key': 'buildType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'create_time': {'key': 'createTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'output_image_manifests': {'key': 'outputImageManifests', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'build_task_name': {'key': 'buildTaskName', 'type': 'str'}, + "build_id": {"key": "buildId", "type": "str"}, + "build_type": {"key": "buildType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "create_time": {"key": "createTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "output_image_manifests": {"key": "outputImageManifests", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "build_task_name": {"key": "buildTaskName", "type": "str"}, } def __init__( self, *, build_id: Optional[str] = None, - build_type: Optional[Union[str, "BuildType"]] = None, - status: Optional[Union[str, "BuildStatus"]] = None, + build_type: Optional[Union[str, "_models.BuildType"]] = None, + status: Optional[Union[str, "_models.BuildStatus"]] = None, create_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, output_image_manifests: Optional[str] = None, @@ -396,11 +383,11 @@ def __init__( """ :keyword build_id: The unique identifier for the build. :paramtype build_id: str - :keyword build_type: The type of build. Possible values include: "AutoBuild", "QuickBuild". + :keyword build_type: The type of build. Known values are: "AutoBuild" and "QuickBuild". :paramtype build_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildType - :keyword status: The current status of the build. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the build. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStatus :keyword create_time: The create time for a build. :paramtype create_time: ~datetime.datetime @@ -414,7 +401,7 @@ def __init__( :keyword build_task_name: The name of the build task that the build corresponds to. :paramtype build_task_name: str """ - super(BuildFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.build_id = build_id self.build_type = build_type self.status = status @@ -425,7 +412,7 @@ def __init__( self.build_task_name = build_task_name -class BuildGetLogResult(msrest.serialization.Model): +class BuildGetLogResult(_serialization.Model): """The result of get log link operation. :ivar log_link: The link to logs for a azure container registry build. @@ -433,24 +420,19 @@ class BuildGetLogResult(msrest.serialization.Model): """ _attribute_map = { - 'log_link': {'key': 'logLink', 'type': 'str'}, + "log_link": {"key": "logLink", "type": "str"}, } - def __init__( - self, - *, - log_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, log_link: Optional[str] = None, **kwargs): """ :keyword log_link: The link to logs for a azure container registry build. :paramtype log_link: str """ - super(BuildGetLogResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_link = log_link -class BuildListResult(msrest.serialization.Model): +class BuildListResult(_serialization.Model): """Collection of builds. :ivar value: The collection value. @@ -460,24 +442,18 @@ class BuildListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Build]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Build]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Build"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Build"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(BuildListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -499,34 +475,29 @@ class BuildStep(ProxyResource): """ _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'}, - 'properties': {'key': 'properties', 'type': 'BuildStepProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BuildStepProperties"}, } - def __init__( - self, - *, - properties: Optional["BuildStepProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BuildStepProperties"] = None, **kwargs): """ :keyword properties: The properties of a build step. :paramtype properties: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepProperties """ - super(BuildStep, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BuildStepList(msrest.serialization.Model): +class BuildStepList(_serialization.Model): """The collection of build items. :ivar value: The collection value. @@ -536,128 +507,108 @@ class BuildStepList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildStep]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildStep]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["BuildStep"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.BuildStep"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(BuildStepList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildStepProperties(msrest.serialization.Model): +class BuildStepProperties(_serialization.Model): """Base properties for any build step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStep. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStep 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 provisioning_state: The provisioning state of the build step. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of the build step. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.ProvisioningState - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker". + :ivar type: The type of the step. Required. "Docker" :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepType """ _validation = { - 'provisioning_state': {'readonly': True}, - 'type': {'required': True, 'readonly': True}, + "provisioning_state": {"readonly": True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - _subtype_map = { - 'type': {'Docker': 'DockerBuildStep'} - } + _subtype_map = {"type": {"Docker": "DockerBuildStep"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStepProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None - self.type = None # type: Optional[str] + self.type: Optional[str] = None -class BuildStepPropertiesUpdateParameters(msrest.serialization.Model): +class BuildStepPropertiesUpdateParameters(_serialization.Model): """The properties for updating a build step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStepUpdateParameters. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStepUpdateParameters 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 the step.Constant filled by server. Possible values include: - "Docker". + :ivar type: The type of the step. Required. "Docker" :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepType """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } - _subtype_map = { - 'type': {'Docker': 'DockerBuildStepUpdateParameters'} - } + _subtype_map = {"type": {"Docker": "DockerBuildStepUpdateParameters"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(BuildStepPropertiesUpdateParameters, self).__init__(**kwargs) - self.type = None # type: Optional[str] + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None -class BuildStepUpdateParameters(msrest.serialization.Model): +class BuildStepUpdateParameters(_serialization.Model): """The parameters for updating a build step. :ivar properties: The properties for updating a build step. :vartype properties: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepPropertiesUpdateParameters - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'BuildStepPropertiesUpdateParameters'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "properties": {"key": "properties", "type": "BuildStepPropertiesUpdateParameters"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: Optional["BuildStepPropertiesUpdateParameters"] = None, + properties: Optional["_models.BuildStepPropertiesUpdateParameters"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -665,15 +616,15 @@ def __init__( :keyword properties: The properties for updating a build step. :paramtype properties: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepPropertiesUpdateParameters - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] """ - super(BuildStepUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.tags = tags -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -686,43 +637,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -730,7 +675,7 @@ def __init__( self.tags = tags -class BuildTask(Resource): +class BuildTask(Resource): # pylint: disable=too-many-instance-attributes """The build task that has the resource properties and all build items. The build task will have all information to schedule a build against it. Variables are only populated by the server, and will be ignored when sending a request. @@ -743,20 +688,20 @@ class BuildTask(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar provisioning_state: The provisioning state of the build task. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of the build task. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.ProvisioningState :ivar creation_date: The creation date of build task. :vartype creation_date: ~datetime.datetime :ivar alias: The alternative updatable name for a build task. :vartype alias: str - :ivar status: The current status of build task. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of build task. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskStatus :ivar source_repository: The properties that describes the source(code) for the build task. @@ -769,28 +714,28 @@ class BuildTask(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "creation_date": {"readonly": True}, + "timeout": {"maximum": 28800, "minimum": 300}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'source_repository': {'key': 'properties.sourceRepository', 'type': 'SourceRepositoryProperties'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "alias": {"key": "properties.alias", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "source_repository": {"key": "properties.sourceRepository", "type": "SourceRepositoryProperties"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, } def __init__( @@ -799,22 +744,21 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, alias: Optional[str] = None, - status: Optional[Union[str, "BuildTaskStatus"]] = None, - source_repository: Optional["SourceRepositoryProperties"] = None, - platform: Optional["PlatformProperties"] = None, - timeout: Optional[int] = 3600, + status: Optional[Union[str, "_models.BuildTaskStatus"]] = None, + source_repository: Optional["_models.SourceRepositoryProperties"] = None, + platform: Optional["_models.PlatformProperties"] = None, + timeout: int = 3600, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword alias: The alternative updatable name for a build task. :paramtype alias: str - :keyword status: The current status of build task. Possible values include: "Disabled", - "Enabled". + :keyword status: The current status of build task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskStatus :keyword source_repository: The properties that describes the source(code) for the build task. @@ -826,7 +770,7 @@ def __init__( :keyword timeout: Build timeout in seconds. :paramtype timeout: int """ - super(BuildTask, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.creation_date = None self.alias = alias @@ -836,40 +780,34 @@ def __init__( self.timeout = timeout -class QueueBuildRequest(msrest.serialization.Model): +class QueueBuildRequest(_serialization.Model): """The queue build request parameters. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BuildTaskBuildRequest, QuickBuildRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BuildTaskBuildRequest, QuickBuildRequest 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 the build request.Constant filled by server. + :ivar type: The type of the build request. Required. :vartype type: str """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } - _subtype_map = { - 'type': {'BuildTask': 'BuildTaskBuildRequest', 'QuickBuild': 'QuickBuildRequest'} - } + _subtype_map = {"type": {"BuildTask": "BuildTaskBuildRequest", "QuickBuild": "QuickBuildRequest"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(QueueBuildRequest, self).__init__(**kwargs) - self.type = None # type: Optional[str] + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None class BuildTaskBuildRequest(QueueBuildRequest): @@ -879,39 +817,34 @@ class BuildTaskBuildRequest(QueueBuildRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the build request.Constant filled by server. + :ivar type: The type of the build request. Required. :vartype type: str - :ivar build_task_name: Required. The name of build task against which build has to be queued. + :ivar build_task_name: The name of build task against which build has to be queued. Required. :vartype build_task_name: str """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'build_task_name': {'required': True}, + "type": {"required": True, "readonly": True}, + "build_task_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'build_task_name': {'key': 'buildTaskName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "build_task_name": {"key": "buildTaskName", "type": "str"}, } - def __init__( - self, - *, - build_task_name: str, - **kwargs - ): + def __init__(self, *, build_task_name: str, **kwargs): """ - :keyword build_task_name: Required. The name of build task against which build has to be - queued. + :keyword build_task_name: The name of build task against which build has to be queued. + Required. :paramtype build_task_name: str """ - super(BuildTaskBuildRequest, self).__init__(**kwargs) - self.type = 'BuildTask' # type: str + super().__init__(**kwargs) + self.type: str = "BuildTask" self.build_task_name = build_task_name -class BuildTaskFilter(msrest.serialization.Model): +class BuildTaskFilter(_serialization.Model): """The filter that can be used for listing build tasks. :ivar alias: The alternative name for build task. @@ -919,24 +852,19 @@ class BuildTaskFilter(msrest.serialization.Model): """ _attribute_map = { - 'alias': {'key': 'alias', 'type': 'str'}, + "alias": {"key": "alias", "type": "str"}, } - def __init__( - self, - *, - alias: Optional[str] = None, - **kwargs - ): + def __init__(self, *, alias: Optional[str] = None, **kwargs): """ :keyword alias: The alternative name for build task. :paramtype alias: str """ - super(BuildTaskFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.alias = alias -class BuildTaskListResult(msrest.serialization.Model): +class BuildTaskListResult(_serialization.Model): """The collection of build tasks. :ivar value: The collection value. @@ -946,36 +874,30 @@ class BuildTaskListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[BuildTask]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BuildTask]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["BuildTask"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.BuildTask"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(BuildTaskListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class BuildTaskUpdateParameters(msrest.serialization.Model): +class BuildTaskUpdateParameters(_serialization.Model): """The parameters for updating a build task. - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] :ivar alias: The alternative updatable name for a build task. :vartype alias: str - :ivar status: The current status of build task. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of build task. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskStatus :ivar platform: The platform properties against which the build has to happen. @@ -988,16 +910,16 @@ class BuildTaskUpdateParameters(msrest.serialization.Model): """ _validation = { - 'timeout': {'maximum': 28800, 'minimum': 300}, + "timeout": {"maximum": 28800, "minimum": 300}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'source_repository': {'key': 'properties.sourceRepository', 'type': 'SourceRepositoryUpdateParameters'}, + "tags": {"key": "tags", "type": "{str}"}, + "alias": {"key": "properties.alias", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "source_repository": {"key": "properties.sourceRepository", "type": "SourceRepositoryUpdateParameters"}, } def __init__( @@ -1005,19 +927,18 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, alias: Optional[str] = None, - status: Optional[Union[str, "BuildTaskStatus"]] = None, - platform: Optional["PlatformProperties"] = None, + status: Optional[Union[str, "_models.BuildTaskStatus"]] = None, + platform: Optional["_models.PlatformProperties"] = None, timeout: Optional[int] = None, - source_repository: Optional["SourceRepositoryUpdateParameters"] = None, + source_repository: Optional["_models.SourceRepositoryUpdateParameters"] = None, **kwargs ): """ - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] :keyword alias: The alternative updatable name for a build task. :paramtype alias: str - :keyword status: The current status of build task. Possible values include: "Disabled", - "Enabled". + :keyword status: The current status of build task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskStatus :keyword platform: The platform properties against which the build has to happen. @@ -1029,7 +950,7 @@ def __init__( :paramtype source_repository: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceRepositoryUpdateParameters """ - super(BuildTaskUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.alias = alias self.status = status @@ -1038,7 +959,7 @@ def __init__( self.source_repository = source_repository -class BuildUpdateParameters(msrest.serialization.Model): +class BuildUpdateParameters(_serialization.Model): """The set of build properties that can be updated. :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -1046,36 +967,30 @@ class BuildUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(BuildUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_archive_enabled = is_archive_enabled -class DockerBuildStep(BuildStepProperties): +class DockerBuildStep(BuildStepProperties): # pylint: disable=too-many-instance-attributes """The Docker build step. 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 provisioning_state: The provisioning state of the build step. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of the build step. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.ProvisioningState - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker". + :ivar type: The type of the step. Required. "Docker" :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepType :ivar branch: The repository branch name. :vartype branch: str @@ -1096,30 +1011,30 @@ class DockerBuildStep(BuildStepProperties): :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageDependency] - :ivar base_image_trigger: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime", "None". + :ivar base_image_trigger: The type of the auto trigger for base image dependency updates. Known + values are: "All", "Runtime", and "None". :vartype base_image_trigger: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageTriggerType """ _validation = { - 'provisioning_state': {'readonly': True}, - 'type': {'required': True, 'readonly': True}, - 'base_image_dependencies': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "type": {"required": True, "readonly": True}, + "base_image_dependencies": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'build_arguments': {'key': 'buildArguments', 'type': '[BuildArgument]'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "build_arguments": {"key": "buildArguments", "type": "[BuildArgument]"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "str"}, } def __init__( @@ -1127,12 +1042,12 @@ def __init__( *, branch: Optional[str] = None, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, docker_file_path: Optional[str] = None, context_path: Optional[str] = None, - build_arguments: Optional[List["BuildArgument"]] = None, - base_image_trigger: Optional[Union[str, "BaseImageTriggerType"]] = None, + build_arguments: Optional[List["_models.BuildArgument"]] = None, + base_image_trigger: Optional[Union[str, "_models.BaseImageTriggerType"]] = None, **kwargs ): """ @@ -1154,12 +1069,12 @@ def __init__( :paramtype build_arguments: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgument] :keyword base_image_trigger: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime", "None". + Known values are: "All", "Runtime", and "None". :paramtype base_image_trigger: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageTriggerType """ - super(DockerBuildStep, self).__init__(**kwargs) - self.type = 'Docker' # type: str + super().__init__(**kwargs) + self.type: str = "Docker" self.branch = branch self.image_names = image_names self.is_push_enabled = is_push_enabled @@ -1178,8 +1093,7 @@ class DockerBuildStepUpdateParameters(BuildStepPropertiesUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker". + :ivar type: The type of the step. Required. "Docker" :vartype type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepType :ivar branch: The repository branch name. :vartype branch: str @@ -1197,26 +1111,26 @@ class DockerBuildStepUpdateParameters(BuildStepPropertiesUpdateParameters): :ivar build_arguments: The custom arguments for building this build step. :vartype build_arguments: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgument] - :ivar base_image_trigger: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime", "None". + :ivar base_image_trigger: The type of the auto trigger for base image dependency updates. Known + values are: "All", "Runtime", and "None". :vartype base_image_trigger: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageTriggerType """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'build_arguments': {'key': 'buildArguments', 'type': '[BuildArgument]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "build_arguments": {"key": "buildArguments", "type": "[BuildArgument]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "str"}, } def __init__( @@ -1228,8 +1142,8 @@ def __init__( no_cache: Optional[bool] = None, docker_file_path: Optional[str] = None, context_path: Optional[str] = None, - build_arguments: Optional[List["BuildArgument"]] = None, - base_image_trigger: Optional[Union[str, "BaseImageTriggerType"]] = None, + build_arguments: Optional[List["_models.BuildArgument"]] = None, + base_image_trigger: Optional[Union[str, "_models.BaseImageTriggerType"]] = None, **kwargs ): """ @@ -1251,12 +1165,12 @@ def __init__( :paramtype build_arguments: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgument] :keyword base_image_trigger: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime", "None". + Known values are: "All", "Runtime", and "None". :paramtype base_image_trigger: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BaseImageTriggerType """ - super(DockerBuildStepUpdateParameters, self).__init__(**kwargs) - self.type = 'Docker' # type: str + super().__init__(**kwargs) + self.type: str = "Docker" self.branch = branch self.image_names = image_names self.is_push_enabled = is_push_enabled @@ -1267,7 +1181,7 @@ def __init__( self.base_image_trigger = base_image_trigger -class GitCommitTrigger(msrest.serialization.Model): +class GitCommitTrigger(_serialization.Model): """The git commit trigger that caused a build. :ivar id: The unique ID of the trigger. @@ -1283,17 +1197,17 @@ class GitCommitTrigger(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'commit_id': {'key': 'commitId', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch_name': {'key': 'branchName', 'type': 'str'}, - 'provider_type': {'key': 'providerType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "commit_id": {"key": "commitId", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch_name": {"key": "branchName", "type": "str"}, + "provider_type": {"key": "providerType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin commit_id: Optional[str] = None, repository_url: Optional[str] = None, branch_name: Optional[str] = None, @@ -1312,7 +1226,7 @@ def __init__( :keyword provider_type: The source control provider type. :paramtype provider_type: str """ - super(GitCommitTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.commit_id = commit_id self.repository_url = repository_url @@ -1320,7 +1234,7 @@ def __init__( self.provider_type = provider_type -class ImageDescriptor(msrest.serialization.Model): +class ImageDescriptor(_serialization.Model): """Properties for a registry image. :ivar registry: The registry login server. @@ -1334,10 +1248,10 @@ class ImageDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( @@ -1359,14 +1273,14 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(ImageDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry = registry self.repository = repository self.tag = tag self.digest = digest -class ImageUpdateTrigger(msrest.serialization.Model): +class ImageUpdateTrigger(_serialization.Model): """The image update trigger that caused a build. :ivar id: The unique ID of the trigger. @@ -1378,17 +1292,17 @@ class ImageUpdateTrigger(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'images': {'key': 'images', 'type': '[ImageDescriptor]'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "images": {"key": "images", "type": "[ImageDescriptor]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, - images: Optional[List["ImageDescriptor"]] = None, + images: Optional[List["_models.ImageDescriptor"]] = None, **kwargs ): """ @@ -1400,48 +1314,42 @@ def __init__( :paramtype images: list[~azure.mgmt.containerregistry.v2018_02_01_preview.models.ImageDescriptor] """ - super(ImageUpdateTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.images = images -class PlatformProperties(msrest.serialization.Model): +class PlatformProperties(_serialization.Model): """The platform properties against which the build has to happen. All required parameters must be populated in order to send to Azure. - :ivar os_type: Required. The operating system type required for the build. Possible values - include: "Windows", "Linux". + :ivar os_type: The operating system type required for the build. Required. Known values are: + "Windows" and "Linux". :vartype os_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.OsType :ivar cpu: The CPU configuration in terms of number of cores required for the build. :vartype cpu: int """ _validation = { - 'os_type': {'required': True}, + "os_type": {"required": True}, } _attribute_map = { - 'os_type': {'key': 'osType', 'type': 'str'}, - 'cpu': {'key': 'cpu', 'type': 'int'}, + "os_type": {"key": "osType", "type": "str"}, + "cpu": {"key": "cpu", "type": "int"}, } - def __init__( - self, - *, - os_type: Union[str, "OsType"], - cpu: Optional[int] = None, - **kwargs - ): + def __init__(self, *, os_type: Union[str, "_models.OsType"], cpu: Optional[int] = None, **kwargs): """ - :keyword os_type: Required. The operating system type required for the build. Possible values - include: "Windows", "Linux". + :keyword os_type: The operating system type required for the build. Required. Known values are: + "Windows" and "Linux". :paramtype os_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.OsType :keyword cpu: The CPU configuration in terms of number of cores required for the build. :paramtype cpu: int """ - super(PlatformProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.os_type = os_type self.cpu = cpu @@ -1453,14 +1361,14 @@ class QuickBuildRequest(QueueBuildRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the build request.Constant filled by server. + :ivar type: The type of the build request. Required. :vartype type: str :ivar image_names: The fully qualified image names including the repository and tag. :vartype image_names: list[str] - :ivar source_location: Required. The URL(absolute or relative) of the source that needs to be - built. For Docker build, it can be an URL to a tar or github repository as supported by Docker. + :ivar source_location: The URL(absolute or relative) of the source that needs to be built. For + Docker build, it can be an URL to a tar or github repository as supported by Docker. If it is relative URL, the relative path should be obtained from calling getSourceUploadUrl - API. + API. Required. :vartype source_location: str :ivar build_arguments: The collection of build arguments to be used. :vartype build_arguments: @@ -1472,53 +1380,52 @@ class QuickBuildRequest(QueueBuildRequest): :vartype no_cache: bool :ivar timeout: Build timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the build will happen. + :ivar platform: The platform properties against which the build will happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.PlatformProperties - :ivar docker_file_path: Required. The Docker file path relative to the source location. + :ivar docker_file_path: The Docker file path relative to the source location. Required. :vartype docker_file_path: str """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'source_location': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, - 'docker_file_path': {'required': True}, + "type": {"required": True, "readonly": True}, + "source_location": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, + "docker_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'build_arguments': {'key': 'buildArguments', 'type': '[BuildArgument]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "build_arguments": {"key": "buildArguments", "type": "[BuildArgument]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, } def __init__( self, *, source_location: str, - platform: "PlatformProperties", + platform: "_models.PlatformProperties", docker_file_path: str, image_names: Optional[List[str]] = None, - build_arguments: Optional[List["BuildArgument"]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, - timeout: Optional[int] = 3600, + build_arguments: Optional[List["_models.BuildArgument"]] = None, + is_push_enabled: bool = True, + no_cache: bool = False, + timeout: int = 3600, **kwargs ): """ :keyword image_names: The fully qualified image names including the repository and tag. :paramtype image_names: list[str] - :keyword source_location: Required. The URL(absolute or relative) of the source that needs to - be built. For Docker build, it can be an URL to a tar or github repository as supported by - Docker. + :keyword source_location: The URL(absolute or relative) of the source that needs to be built. + For Docker build, it can be an URL to a tar or github repository as supported by Docker. If it is relative URL, the relative path should be obtained from calling getSourceUploadUrl - API. + API. Required. :paramtype source_location: str :keyword build_arguments: The collection of build arguments to be used. :paramtype build_arguments: @@ -1531,14 +1438,14 @@ def __init__( :paramtype no_cache: bool :keyword timeout: Build timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the build will happen. + :keyword platform: The platform properties against which the build will happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.PlatformProperties - :keyword docker_file_path: Required. The Docker file path relative to the source location. + :keyword docker_file_path: The Docker file path relative to the source location. Required. :paramtype docker_file_path: str """ - super(QuickBuildRequest, self).__init__(**kwargs) - self.type = 'QuickBuild' # type: str + super().__init__(**kwargs) + self.type: str = "QuickBuild" self.image_names = image_names self.source_location = source_location self.build_arguments = build_arguments @@ -1549,14 +1456,14 @@ def __init__( self.docker_file_path = docker_file_path -class SourceControlAuthInfo(msrest.serialization.Model): +class SourceControlAuthInfo(_serialization.Model): """The authorization properties for accessing the source code repository. All required parameters must be populated in order to send to Azure. - :ivar token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.TokenType - :ivar token: Required. The access token used to access the source control provider. + :ivar token: The access token used to access the source control provider. Required. :vartype token: str :ivar refresh_token: The refresh token used to refresh the access token. :vartype refresh_token: str @@ -1567,32 +1474,32 @@ class SourceControlAuthInfo(msrest.serialization.Model): """ _validation = { - 'token': {'required': True}, + "token": {"required": True}, } _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, token: str, - token_type: Optional[Union[str, "TokenType"]] = None, + token_type: Optional[Union[str, "_models.TokenType"]] = None, refresh_token: Optional[str] = None, scope: Optional[str] = None, expires_in: Optional[int] = None, **kwargs ): """ - :keyword token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.TokenType - :keyword token: Required. The access token used to access the source control provider. + :keyword token: The access token used to access the source control provider. Required. :paramtype token: str :keyword refresh_token: The refresh token used to refresh the access token. :paramtype refresh_token: str @@ -1601,7 +1508,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(SourceControlAuthInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -1609,16 +1516,16 @@ def __init__( self.expires_in = expires_in -class SourceRepositoryProperties(msrest.serialization.Model): +class SourceRepositoryProperties(_serialization.Model): """The properties of the source code repository. All required parameters must be populated in order to send to Azure. - :ivar source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceControlType - :ivar repository_url: Required. The full URL to the source code repository. + :ivar repository_url: The full URL to the source code repository. Required. :vartype repository_url: str :ivar is_commit_trigger_enabled: The value of this property indicates whether the source control commit trigger is enabled or not. @@ -1630,32 +1537,32 @@ class SourceRepositoryProperties(msrest.serialization.Model): """ _validation = { - 'source_control_type': {'required': True}, - 'repository_url': {'required': True}, + "source_control_type": {"required": True}, + "repository_url": {"required": True}, } _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'is_commit_trigger_enabled': {'key': 'isCommitTriggerEnabled', 'type': 'bool'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'SourceControlAuthInfo'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "is_commit_trigger_enabled": {"key": "isCommitTriggerEnabled", "type": "bool"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "SourceControlAuthInfo"}, } def __init__( self, *, - source_control_type: Union[str, "SourceControlType"], + source_control_type: Union[str, "_models.SourceControlType"], repository_url: str, - is_commit_trigger_enabled: Optional[bool] = False, - source_control_auth_properties: Optional["SourceControlAuthInfo"] = None, + is_commit_trigger_enabled: bool = False, + source_control_auth_properties: Optional["_models.SourceControlAuthInfo"] = None, **kwargs ): """ - :keyword source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceControlType - :keyword repository_url: Required. The full URL to the source code repository. + :keyword repository_url: The full URL to the source code repository. Required. :paramtype repository_url: str :keyword is_commit_trigger_enabled: The value of this property indicates whether the source control commit trigger is enabled or not. @@ -1665,14 +1572,14 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceControlAuthInfo """ - super(SourceRepositoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.is_commit_trigger_enabled = is_commit_trigger_enabled self.source_control_auth_properties = source_control_auth_properties -class SourceRepositoryUpdateParameters(msrest.serialization.Model): +class SourceRepositoryUpdateParameters(_serialization.Model): """The properties for updating the source code repository configuration. :ivar source_control_auth_properties: The authorization properties for accessing the source @@ -1685,14 +1592,14 @@ class SourceRepositoryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'SourceControlAuthInfo'}, - 'is_commit_trigger_enabled': {'key': 'isCommitTriggerEnabled', 'type': 'bool'}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "SourceControlAuthInfo"}, + "is_commit_trigger_enabled": {"key": "isCommitTriggerEnabled", "type": "bool"}, } def __init__( self, *, - source_control_auth_properties: Optional["SourceControlAuthInfo"] = None, + source_control_auth_properties: Optional["_models.SourceControlAuthInfo"] = None, is_commit_trigger_enabled: Optional[bool] = None, **kwargs ): @@ -1705,12 +1612,12 @@ def __init__( control commit trigger is enabled or not. :paramtype is_commit_trigger_enabled: bool """ - super(SourceRepositoryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_auth_properties = source_control_auth_properties self.is_commit_trigger_enabled = is_commit_trigger_enabled -class SourceUploadDefinition(msrest.serialization.Model): +class SourceUploadDefinition(_serialization.Model): """The properties of a response to source upload request. :ivar upload_url: The URL where the client can upload the source. @@ -1721,17 +1628,11 @@ class SourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } - def __init__( - self, - *, - upload_url: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, upload_url: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword upload_url: The URL where the client can upload the source. :paramtype upload_url: str @@ -1739,6 +1640,6 @@ def __init__( queue build request. :paramtype relative_path: str """ - super(SourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.upload_url = upload_url self.relative_path = relative_path diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/__init__.py index 3f9b755bf5d2..cf2f497714be 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/__init__.py @@ -11,9 +11,15 @@ from ._build_tasks_operations import BuildTasksOperations from ._registries_operations import RegistriesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'BuildsOperations', - 'BuildStepsOperations', - 'BuildTasksOperations', - 'RegistriesOperations', + "BuildsOperations", + "BuildStepsOperations", + "BuildTasksOperations", + "RegistriesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_steps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_steps_operations.py index 611779100c3b..5dc55e0e1c33 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_steps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_steps_operations.py @@ -6,351 +6,393 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, registry_name: str, build_task_name: str, step_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "stepName": _SERIALIZER.url("step_name", step_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "stepName": _SERIALIZER.url( + "step_name", step_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + 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, registry_name: str, build_task_name: str, step_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "stepName": _SERIALIZER.url("step_name", step_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "stepName": _SERIALIZER.url( + "step_name", step_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "stepName": _SERIALIZER.url("step_name", step_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "stepName": _SERIALIZER.url( + "step_name", step_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, + +def build_update_request( resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "stepName": _SERIALIZER.url("step_name", step_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "stepName": _SERIALIZER.url( + "step_name", step_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_build_arguments_request( - subscription_id: str, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "stepName": _SERIALIZER.url("step_name", step_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "stepName": _SERIALIZER.url( + "step_name", step_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class BuildStepsOperations(object): - """BuildStepsOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class BuildStepsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`build_steps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildStepList"]: + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> Iterable["_models.BuildStep"]: """List all the build steps for a given build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildStepList or the result of cls(response) + :return: An iterator like instance of either BuildStep or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildStepList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStepList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - build_task_name=build_task_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -361,16 +403,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BuildStepList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -380,78 +420,82 @@ 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.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any - ) -> "_models.BuildStep": + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any + ) -> _models.BuildStep: """Gets the build step for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildStep, or the result of cls(response) + :return: BuildStep or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } def _create_initial( self, @@ -459,39 +503,55 @@ def _create_initial( registry_name: str, build_task_name: str, step_name: str, - build_step_create_parameters: "_models.BuildStep", + build_step_create_parameters: Union[_models.BuildStep, IO], **kwargs: Any - ) -> "_models.BuildStep": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] + ) -> _models.BuildStep: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_step_create_parameters, 'BuildStep') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_step_create_parameters, (IO, bytes)): + _content = build_step_create_parameters + else: + _json = self._serialize.body(build_step_create_parameters, "BuildStep") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -499,18 +559,104 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_create_parameters: _models.BuildStep, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildStep]: + """Creates a build step for a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_create_parameters: The parameters for creating a build step. Required. + :type build_step_create_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep + :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 BuildStep or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildStep]: + """Creates a build step for a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_create_parameters: The parameters for creating a build step. Required. + :type build_step_create_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 BuildStep or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -519,23 +665,27 @@ def begin_create( registry_name: str, build_task_name: str, step_name: str, - build_step_create_parameters: "_models.BuildStep", + build_step_create_parameters: Union[_models.BuildStep, IO], **kwargs: Any - ) -> LROPoller["_models.BuildStep"]: + ) -> LROPoller[_models.BuildStep]: """Creates a build step for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str - :param build_step_create_parameters: The parameters for creating a build step. + :param build_step_create_parameters: The parameters for creating a build step. Is either a + model type or a IO type. Required. :type build_step_create_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep 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 @@ -547,17 +697,19 @@ def begin_create( :return: An instance of LROPoller that returns either BuildStep or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -567,67 +719,75 @@ def begin_create( build_step_create_parameters=build_step_create_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -637,28 +797,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a build step from the build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_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. @@ -670,46 +826,54 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } def _update_initial( self, @@ -717,39 +881,55 @@ def _update_initial( registry_name: str, build_task_name: str, step_name: str, - build_step_update_parameters: "_models.BuildStepUpdateParameters", + build_step_update_parameters: Union[_models.BuildStepUpdateParameters, IO], **kwargs: Any - ) -> "_models.BuildStep": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] + ) -> _models.BuildStep: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_step_update_parameters, 'BuildStepUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_step_update_parameters, (IO, bytes)): + _content = build_step_update_parameters + else: + _json = self._serialize.body(build_step_update_parameters, "BuildStepUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -757,18 +937,104 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_update_parameters: _models.BuildStepUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildStep]: + """Updates a build step in a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_update_parameters: The parameters for updating a build step. Required. + :type build_step_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters + :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 BuildStep or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + step_name: str, + build_step_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildStep]: + """Updates a build step in a build task. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param step_name: The name of a build step for a container registry build task. Required. + :type step_name: str + :param build_step_update_parameters: The parameters for updating a build step. Required. + :type build_step_update_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 BuildStep or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -777,23 +1043,27 @@ def begin_update( registry_name: str, build_task_name: str, step_name: str, - build_step_update_parameters: "_models.BuildStepUpdateParameters", + build_step_update_parameters: Union[_models.BuildStepUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.BuildStep"]: + ) -> LROPoller[_models.BuildStep]: """Updates a build step in a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str - :param build_step_update_parameters: The parameters for updating a build step. + :param build_step_update_parameters: The parameters for updating a build step. Is either a + model type or a IO type. Required. :type build_step_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStepUpdateParameters 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 @@ -805,17 +1075,19 @@ def begin_update( :return: An instance of LROPoller that returns either BuildStep or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildStep] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildStep"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildStep] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -825,91 +1097,104 @@ def begin_update( build_step_update_parameters=build_step_update_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildStep', pipeline_response) + deserialized = self._deserialize("BuildStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}" + } @distributed_trace def list_build_arguments( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - step_name: str, - **kwargs: Any - ) -> Iterable["_models.BuildArgumentList"]: + self, resource_group_name: str, registry_name: str, build_task_name: str, step_name: str, **kwargs: Any + ) -> Iterable["_models.BuildArgument"]: """List the build arguments for a step including the secret arguments. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param step_name: The name of a build step for a container registry build task. + :param step_name: The name of a build step for a container registry build task. Required. :type step_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildArgumentList or the result of cls(response) + :return: An iterator like instance of either BuildArgument or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgumentList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildArgument] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildArgumentList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildArgumentList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_build_arguments_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, step_name=step_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_build_arguments.metadata['url'], + template_url=self.list_build_arguments.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_build_arguments_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - build_task_name=build_task_name, - step_name=step_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -920,16 +1205,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BuildArgumentList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -939,8 +1222,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_build_arguments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments"} # type: ignore + list_build_arguments.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/steps/{stepName}/listBuildArguments" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_tasks_operations.py index 9c33d7dac1e0..d9c477575d64 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_build_tasks_operations.py @@ -6,292 +6,296 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, registry_name: str, + subscription_id: str, *, filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if skip_token is not None: - _query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - build_task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_source_repository_properties_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, build_task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildTaskName": _SERIALIZER.url("build_task_name", build_task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildTaskName": _SERIALIZER.url( + "build_task_name", build_task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class BuildTasksOperations(object): - """BuildTasksOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class BuildTasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`build_tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -301,13 +305,13 @@ def list( filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.BuildTaskListResult"]: + ) -> Iterable["_models.BuildTask"]: """Lists all the build tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The build task filter to apply on the operation. Default value is None. :type filter: str @@ -315,43 +319,56 @@ def list( page in the list of tasks. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildTaskListResult or the result of cls(response) + :return: An iterator like instance of either BuildTask or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildTaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, skip_token=skip_token, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - skip_token=skip_token, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -362,16 +379,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BuildTaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -381,112 +396,133 @@ 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.ContainerRegistry/registries/{registryName}/buildTasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> "_models.BuildTask": + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> _models.BuildTask: """Get the properties of a specified build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildTask, or the result of cls(response) + :return: BuildTask or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, build_task_name: str, - build_task_create_parameters: "_models.BuildTask", + build_task_create_parameters: Union[_models.BuildTask, IO], **kwargs: Any - ) -> "_models.BuildTask": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] + ) -> _models.BuildTask: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(build_task_create_parameters, 'BuildTask') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_task_create_parameters, (IO, bytes)): + _content = build_task_create_parameters + else: + _json = self._serialize.body(build_task_create_parameters, "BuildTask") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -494,18 +530,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_create_parameters: _models.BuildTask, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildTask]: + """Creates a build task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_create_parameters: The parameters for creating a build task. Required. + :type build_task_create_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask + :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 BuildTask or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildTask]: + """Creates a build task for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_create_parameters: The parameters for creating a build task. Required. + :type build_task_create_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 BuildTask or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -513,21 +629,25 @@ def begin_create( resource_group_name: str, registry_name: str, build_task_name: str, - build_task_create_parameters: "_models.BuildTask", + build_task_create_parameters: Union[_models.BuildTask, IO], **kwargs: Any - ) -> LROPoller["_models.BuildTask"]: + ) -> LROPoller[_models.BuildTask]: """Creates a build task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param build_task_create_parameters: The parameters for creating a build task. + :param build_task_create_parameters: The parameters for creating a build task. Is either a + model type or a IO type. Required. :type build_task_create_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask 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 @@ -539,17 +659,19 @@ def begin_create( :return: An instance of LROPoller that returns either BuildTask or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -558,65 +680,74 @@ def begin_create( build_task_create_parameters=build_task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -626,25 +757,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_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. @@ -656,83 +784,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, build_task_name: str, - build_task_update_parameters: "_models.BuildTaskUpdateParameters", + build_task_update_parameters: Union[_models.BuildTaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.BuildTask": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] + ) -> _models.BuildTask: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(build_task_update_parameters, 'BuildTaskUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_task_update_parameters, (IO, bytes)): + _content = build_task_update_parameters + else: + _json = self._serialize.body(build_task_update_parameters, "BuildTaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -740,18 +892,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_update_parameters: _models.BuildTaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildTask]: + """Updates a build task with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_update_parameters: The parameters for updating a build task. Required. + :type build_task_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters + :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 BuildTask or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_task_name: str, + build_task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BuildTask]: + """Updates a build task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_task_name: The name of the container registry build task. Required. + :type build_task_name: str + :param build_task_update_parameters: The parameters for updating a build task. Required. + :type build_task_update_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 BuildTask or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -759,21 +991,25 @@ def begin_update( resource_group_name: str, registry_name: str, build_task_name: str, - build_task_update_parameters: "_models.BuildTaskUpdateParameters", + build_task_update_parameters: Union[_models.BuildTaskUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.BuildTask"]: + ) -> LROPoller[_models.BuildTask]: """Updates a build task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str - :param build_task_update_parameters: The parameters for updating a build task. + :param build_task_update_parameters: The parameters for updating a build task. Is either a + model type or a IO type. Required. :type build_task_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTaskUpdateParameters 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 @@ -785,17 +1021,19 @@ def begin_update( :return: An instance of LROPoller that returns either BuildTask or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildTask] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildTask"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BuildTask] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -804,92 +1042,102 @@ def begin_update( build_task_update_parameters=build_task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('BuildTask', pipeline_response) + deserialized = self._deserialize("BuildTask", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}" + } @distributed_trace def list_source_repository_properties( - self, - resource_group_name: str, - registry_name: str, - build_task_name: str, - **kwargs: Any - ) -> "_models.SourceRepositoryProperties": + self, resource_group_name: str, registry_name: str, build_task_name: str, **kwargs: Any + ) -> _models.SourceRepositoryProperties: """Get the source control properties for a build task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_task_name: The name of the container registry build task. + :param build_task_name: The name of the container registry build task. Required. :type build_task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceRepositoryProperties, or the result of cls(response) + :return: SourceRepositoryProperties or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceRepositoryProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceRepositoryProperties"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.SourceRepositoryProperties] = kwargs.pop("cls", None) - request = build_list_source_repository_properties_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_task_name=build_task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_source_repository_properties.metadata['url'], + template_url=self.list_source_repository_properties.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceRepositoryProperties', pipeline_response) + deserialized = self._deserialize("SourceRepositoryProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_source_repository_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties"} # type: ignore - + list_source_repository_properties.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/buildTasks/{buildTaskName}/listSourceRepositoryProperties" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_builds_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_builds_operations.py index 42ce8a53b791..46eb60dd4f1d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_builds_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_builds_operations.py @@ -6,249 +6,250 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, registry_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if skip_token is not None: - _query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - build_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, build_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildId": _SERIALIZER.url("build_id", build_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildId": _SERIALIZER.url("build_id", build_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, build_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildId": _SERIALIZER.url("build_id", build_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildId": _SERIALIZER.url("build_id", build_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_log_link_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, build_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildId": _SERIALIZER.url("build_id", build_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildId": _SERIALIZER.url("build_id", build_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + +def build_cancel_request( + resource_group_name: str, registry_name: str, build_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "buildId": _SERIALIZER.url("build_id", build_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "buildId": _SERIALIZER.url("build_id", build_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class BuildsOperations(object): - """BuildsOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class BuildsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`builds` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -259,13 +260,13 @@ def list( top: Optional[int] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.BuildListResult"]: + ) -> Iterable["_models.Build"]: """Gets all the builds for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The builds filter to apply on the operation. Default value is None. :type filter: str @@ -276,45 +277,57 @@ def list( in the list of builds. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BuildListResult or the result of cls(response) + :return: An iterator like instance of either Build or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, skip_token=skip_token, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - skip_token=skip_token, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -325,16 +338,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("BuildListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -344,112 +355,131 @@ 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.ContainerRegistry/registries/{registryName}/builds"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any - ) -> "_models.Build": + def get(self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any) -> _models.Build: """Gets the detailed information for a given build. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Build, or the result of cls(response) + :return: Build or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } def _update_initial( self, resource_group_name: str, registry_name: str, build_id: str, - build_update_parameters: "_models.BuildUpdateParameters", + build_update_parameters: Union[_models.BuildUpdateParameters, IO], **kwargs: Any - ) -> "_models.Build": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] + ) -> _models.Build: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(build_update_parameters, 'BuildUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_update_parameters, (IO, bytes)): + _content = build_update_parameters + else: + _json = self._serialize.body(build_update_parameters, "BuildUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -457,18 +487,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_id: str, + build_update_parameters: _models.BuildUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Build]: + """Patch the build properties. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_id: The build ID. Required. + :type build_id: str + :param build_update_parameters: The build update properties. Required. + :type build_update_parameters: + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters + :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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + build_id: str, + build_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Build]: + """Patch the build properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_id: The build ID. Required. + :type build_id: str + :param build_update_parameters: The build update properties. Required. + :type build_update_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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -476,21 +586,25 @@ def begin_update( resource_group_name: str, registry_name: str, build_id: str, - build_update_parameters: "_models.BuildUpdateParameters", + build_update_parameters: Union[_models.BuildUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Build"]: + ) -> LROPoller[_models.Build]: """Patch the build properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str - :param build_update_parameters: The build update properties. + :param build_update_parameters: The build update properties. Is either a model type or a IO + type. Required. :type build_update_parameters: - ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters + ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildUpdateParameters 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 @@ -502,17 +616,19 @@ def begin_update( :return: An instance of LROPoller that returns either Build or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -521,128 +637,142 @@ def begin_update( build_update_parameters=build_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}" + } @distributed_trace def get_log_link( - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any - ) -> "_models.BuildGetLogResult": + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any + ) -> _models.BuildGetLogResult: """Gets a link to download the build logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BuildGetLogResult, or the result of cls(response) + :return: BuildGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.BuildGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BuildGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01-preview") # type: str + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.BuildGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_link_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_link.metadata['url'], + template_url=self.get_log_link.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BuildGetLogResult', pipeline_response) + deserialized = self._deserialize("BuildGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_link.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink"} # type: ignore - + get_log_link.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/getLogLink" + } def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -652,25 +782,22 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel" + } @distributed_trace - def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - build_id: str, - **kwargs: Any + def begin_cancel( + self, resource_group_name: str, registry_name: str, build_id: str, **kwargs: Any ) -> LROPoller[None]: """Cancel an existing build. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_id: The build ID. + :param build_id: The build ID. Required. :type build_id: 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. @@ -682,42 +809,50 @@ def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, build_id=build_id, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/builds/{buildId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_registries_operations.py index c23e4d5d6b13..e394f0602d73 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_02_01_preview/operations/_registries_operations.py @@ -6,164 +6,184 @@ # 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, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_queue_build_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_queue_build_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_build_source_upload_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl", + ) # 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'), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class RegistriesOperations(object): - """RegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _queue_build_initial( self, resource_group_name: str, registry_name: str, - build_request: "_models.QueueBuildRequest", + build_request: Union[_models.QueueBuildRequest, IO], **kwargs: Any - ) -> Optional["_models.Build"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Build"]] + ) -> Optional[_models.Build]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(build_request, 'QueueBuildRequest') - - request = build_queue_build_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Build]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(build_request, (IO, bytes)): + _content = build_request + else: + _json = self._serialize.body(build_request, "QueueBuildRequest") + + request = build_queue_build_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._queue_build_initial.metadata['url'], + content=_content, + template_url=self._queue_build_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -172,33 +192,111 @@ def _queue_build_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _queue_build_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild"} # type: ignore + _queue_build_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild" + } + @overload + def begin_queue_build( + self, + resource_group_name: str, + registry_name: str, + build_request: _models.QueueBuildRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Build]: + """Creates a new build based on the request parameters and add it to the build queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_request: The parameters of a build that needs to queued. Required. + :type build_request: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.QueueBuildRequest + :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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_queue_build( + self, + resource_group_name: str, + registry_name: str, + build_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Build]: + """Creates a new build based on the request parameters and add it to the build queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param build_request: The parameters of a build that needs to queued. Required. + :type build_request: 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 Build or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_queue_build( self, resource_group_name: str, registry_name: str, - build_request: "_models.QueueBuildRequest", + build_request: Union[_models.QueueBuildRequest, IO], **kwargs: Any - ) -> LROPoller["_models.Build"]: + ) -> LROPoller[_models.Build]: """Creates a new build based on the request parameters and add it to the build queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param build_request: The parameters of a build that needs to queued. + :param build_request: The parameters of a build that needs to queued. Is either a model type or + a IO type. Required. :type build_request: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.QueueBuildRequest + 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 @@ -210,17 +308,19 @@ def begin_queue_build( :return: An instance of LROPoller that returns either Build or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_02_01_preview.models.Build] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Build"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Build] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._queue_build_initial( resource_group_name=resource_group_name, @@ -228,88 +328,99 @@ def begin_queue_build( build_request=build_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Build', pipeline_response) + deserialized = self._deserialize("Build", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_queue_build.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild"} # type: ignore + begin_queue_build.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild" + } @distributed_trace def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_02_01_preview.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-02-01-preview") + ) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_configuration.py index 7fd9c654023e..5c0706d701fd 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", "2018-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_container_registry_management_client.py index 2713ac1a62c1..ab4206793501 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, RunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -31,9 +31,9 @@ class ContainerRegistryManagementClient: :vartype runs: azure.mgmt.containerregistry.v2018_09_01.operations.RunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2018_09_01.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -51,10 +51,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -62,12 +64,7 @@ def __init__( self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -76,7 +73,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 @@ -89,15 +86,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_metadata.json index 2abf7251afc0..43ed0e31dfd9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -101,4 +101,4 @@ "runs": "RunsOperations", "tasks": "TasksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_configuration.py index bbd0a7a1c9be..4541666f67f3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", "2018-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_container_registry_management_client.py index 0e3931cfc0d1..1f46b94a4a59 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, RunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -32,9 +32,9 @@ class ContainerRegistryManagementClient: :vartype runs: azure.mgmt.containerregistry.v2018_09_01.aio.operations.RunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2018_09_01.aio.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,10 +52,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -63,12 +65,7 @@ def __init__( self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -77,7 +74,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/__init__.py index bb338b8a913c..d0afbe0f997d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._runs_operations import RunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'RunsOperations', - 'TasksOperations', + "RegistriesOperations", + "RunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_registries_operations.py index 54129e781e3d..1eb1323e33ed 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_registries_operations.py @@ -6,80 +6,102 @@ # 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, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request_initial -T = TypeVar('T') +from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -88,33 +110,39 @@ async def _schedule_run_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace_async + @overload async def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest + :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 @@ -126,17 +154,84 @@ async def begin_schedule_run( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._schedule_run_initial( resource_group_name=resource_group_name, @@ -144,88 +239,97 @@ async def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace_async async def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_runs_operations.py index 4a4965d0b8f7..c39a63d22188 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_runs_operations.py @@ -6,46 +6,65 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._runs_operations import build_cancel_request_initial, build_get_log_sas_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._runs_operations import ( + build_cancel_request, + build_get_log_sas_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RunsOperations: - """RunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -55,13 +74,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.RunListResult"]: + ) -> AsyncIterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -71,43 +90,54 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) + :return: An iterator like instance of either Run or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +148,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,112 +165,127 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + async def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -250,18 +293,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -269,21 +392,25 @@ async def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters 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 @@ -295,17 +422,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -314,128 +441,138 @@ async def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace_async async def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } async def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -445,25 +582,22 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace_async - async def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + async def begin_cancel( + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -475,42 +609,48 @@ async def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_tasks_operations.py index 45bf9c001dbf..3163addb4057 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_tasks_operations.py @@ -6,95 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tasks_operations import build_create_request_initial, build_delete_request_initial, build_get_details_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tasks_operations import ( + build_create_request, + build_delete_request, + build_get_details_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TasksOperations: - """TasksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) + :return: An iterator like instance of either Task or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +150,127 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + async def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +278,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,20 +376,24 @@ async def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task 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 @@ -281,17 +405,17 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -300,65 +424,72 @@ async def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -368,25 +499,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -398,83 +526,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -482,18 +630,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -501,21 +729,25 @@ async def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters 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 @@ -527,17 +759,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -546,92 +778,100 @@ async def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async async def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any + ) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/__init__.py index e991bd15594a..b70fb69d7b96 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/__init__.py @@ -54,88 +54,90 @@ from ._models_py3 import TriggerProperties from ._models_py3 import TriggerUpdateParameters - -from ._container_registry_management_client_enums import ( - Architecture, - BaseImageDependencyType, - BaseImageTriggerType, - OS, - ProvisioningState, - RunStatus, - RunType, - SecretObjectType, - SourceControlType, - SourceRegistryLoginMode, - SourceTriggerEvent, - StepType, - TaskStatus, - TokenType, - TriggerStatus, - Variant, -) +from ._container_registry_management_client_enums import Architecture +from ._container_registry_management_client_enums import BaseImageDependencyType +from ._container_registry_management_client_enums import BaseImageTriggerType +from ._container_registry_management_client_enums import OS +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import RunStatus +from ._container_registry_management_client_enums import RunType +from ._container_registry_management_client_enums import SecretObjectType +from ._container_registry_management_client_enums import SourceControlType +from ._container_registry_management_client_enums import SourceRegistryLoginMode +from ._container_registry_management_client_enums import SourceTriggerEvent +from ._container_registry_management_client_enums import StepType +from ._container_registry_management_client_enums import TaskStatus +from ._container_registry_management_client_enums import TokenType +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import Variant +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AgentProperties', - 'Argument', - 'AuthInfo', - 'AuthInfoUpdateParameters', - 'BaseImageDependency', - 'BaseImageTrigger', - 'BaseImageTriggerUpdateParameters', - 'Credentials', - 'CustomRegistryCredentials', - 'DockerBuildRequest', - 'DockerBuildStep', - 'DockerBuildStepUpdateParameters', - 'EncodedTaskRunRequest', - 'EncodedTaskStep', - 'EncodedTaskStepUpdateParameters', - 'FileTaskRunRequest', - 'FileTaskStep', - 'FileTaskStepUpdateParameters', - 'ImageDescriptor', - 'ImageUpdateTrigger', - 'PlatformProperties', - 'PlatformUpdateParameters', - 'ProxyResource', - 'Resource', - 'Run', - 'RunFilter', - 'RunGetLogResult', - 'RunListResult', - 'RunRequest', - 'RunUpdateParameters', - 'SecretObject', - 'SetValue', - 'SourceProperties', - 'SourceRegistryCredentials', - 'SourceTrigger', - 'SourceTriggerDescriptor', - 'SourceTriggerUpdateParameters', - 'SourceUpdateParameters', - 'SourceUploadDefinition', - 'Task', - 'TaskListResult', - 'TaskRunRequest', - 'TaskStepProperties', - 'TaskStepUpdateParameters', - 'TaskUpdateParameters', - 'TriggerProperties', - 'TriggerUpdateParameters', - 'Architecture', - 'BaseImageDependencyType', - 'BaseImageTriggerType', - 'OS', - 'ProvisioningState', - 'RunStatus', - 'RunType', - 'SecretObjectType', - 'SourceControlType', - 'SourceRegistryLoginMode', - 'SourceTriggerEvent', - 'StepType', - 'TaskStatus', - 'TokenType', - 'TriggerStatus', - 'Variant', + "AgentProperties", + "Argument", + "AuthInfo", + "AuthInfoUpdateParameters", + "BaseImageDependency", + "BaseImageTrigger", + "BaseImageTriggerUpdateParameters", + "Credentials", + "CustomRegistryCredentials", + "DockerBuildRequest", + "DockerBuildStep", + "DockerBuildStepUpdateParameters", + "EncodedTaskRunRequest", + "EncodedTaskStep", + "EncodedTaskStepUpdateParameters", + "FileTaskRunRequest", + "FileTaskStep", + "FileTaskStepUpdateParameters", + "ImageDescriptor", + "ImageUpdateTrigger", + "PlatformProperties", + "PlatformUpdateParameters", + "ProxyResource", + "Resource", + "Run", + "RunFilter", + "RunGetLogResult", + "RunListResult", + "RunRequest", + "RunUpdateParameters", + "SecretObject", + "SetValue", + "SourceProperties", + "SourceRegistryCredentials", + "SourceTrigger", + "SourceTriggerDescriptor", + "SourceTriggerUpdateParameters", + "SourceUpdateParameters", + "SourceUploadDefinition", + "Task", + "TaskListResult", + "TaskRunRequest", + "TaskStepProperties", + "TaskStepUpdateParameters", + "TaskUpdateParameters", + "TriggerProperties", + "TriggerUpdateParameters", + "Architecture", + "BaseImageDependencyType", + "BaseImageTriggerType", + "OS", + "ProvisioningState", + "RunStatus", + "RunType", + "SecretObjectType", + "SourceControlType", + "SourceRegistryLoginMode", + "SourceTriggerEvent", + "StepType", + "TaskStatus", + "TokenType", + "TriggerStatus", + "Variant", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_container_registry_management_client_enums.py index 738fbc0f2115..9eb4698b6f62 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_container_registry_management_client_enums.py @@ -7,42 +7,40 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The OS architecture. - """ +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS architecture.""" AMD64 = "amd64" X86 = "x86" ARM = "arm" -class BaseImageDependencyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the base image dependency. - """ + +class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the base image dependency.""" BUILD_TIME = "BuildTime" RUN_TIME = "RunTime" -class BaseImageTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the auto trigger for base image dependency updates. - """ + +class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the auto trigger for base image dependency updates.""" ALL = "All" RUNTIME = "Runtime" -class OS(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operating system type required for the run. - """ + +class OS(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type required for the run.""" WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of a run. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a run.""" CREATING = "Creating" UPDATING = "Updating" @@ -51,9 +49,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the run. - """ + +class RunStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the run.""" QUEUED = "Queued" STARTED = "Started" @@ -64,30 +62,32 @@ class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" TIMEOUT = "Timeout" -class RunType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of run. - """ + +class RunType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of run.""" QUICK_BUILD = "QuickBuild" QUICK_RUN = "QuickRun" AUTO_BUILD = "AutoBuild" AUTO_RUN = "AutoRun" -class SecretObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecretObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the secret object which determines how the value of the secret object has to be interpreted. """ OPAQUE = "Opaque" -class SourceControlType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source control service. - """ + +class SourceControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source control service.""" GITHUB = "Github" VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" -class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceRegistryLoginMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to @@ -97,43 +97,45 @@ class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) NONE = "None" DEFAULT = "Default" -class SourceTriggerEvent(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceTriggerEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SourceTriggerEvent.""" COMMIT = "commit" PULLREQUEST = "pullrequest" -class StepType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the step. - """ + +class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the step.""" DOCKER = "Docker" FILE_TASK = "FileTask" ENCODED_TASK = "EncodedTask" -class TaskStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of task. - """ + +class TaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of task.""" DISABLED = "Disabled" ENABLED = "Enabled" -class TokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of Auth token. - """ + +class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of Auth token.""" PAT = "PAT" O_AUTH = "OAuth" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of trigger.""" DISABLED = "Disabled" ENABLED = "Enabled" -class Variant(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Variant of the CPU. - """ + +class Variant(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Variant of the CPU.""" V6 = "v6" V7 = "v7" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_models_py3.py index fc6e91370162..1900e231787d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AgentProperties(msrest.serialization.Model): +class AgentProperties(_serialization.Model): """The properties that determine the run agent configuration. :ivar cpu: The CPU configuration in terms of number of cores required for the run. @@ -22,31 +25,26 @@ class AgentProperties(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "int"}, } - def __init__( - self, - *, - cpu: Optional[int] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[int] = None, **kwargs): """ :keyword cpu: The CPU configuration in terms of number of cores required for the run. :paramtype cpu: int """ - super(AgentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu -class Argument(msrest.serialization.Model): +class Argument(_serialization.Model): """The properties of a run argument. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the argument. + :ivar name: The name of the argument. Required. :vartype name: str - :ivar value: Required. The value of the argument. + :ivar value: The value of the argument. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. @@ -54,47 +52,40 @@ class Argument(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the argument. + :keyword name: The name of the argument. Required. :paramtype name: str - :keyword value: Required. The value of the argument. + :keyword value: The value of the argument. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. :paramtype is_secret: bool """ - super(Argument, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class AuthInfo(msrest.serialization.Model): +class AuthInfo(_serialization.Model): """The authorization properties for accessing the source code repository. All required parameters must be populated in order to send to Azure. - :ivar token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TokenType - :ivar token: Required. The access token used to access the source control provider. + :ivar token: The access token used to access the source control provider. Required. :vartype token: str :ivar refresh_token: The refresh token used to refresh the access token. :vartype refresh_token: str @@ -105,22 +96,22 @@ class AuthInfo(msrest.serialization.Model): """ _validation = { - 'token_type': {'required': True}, - 'token': {'required': True}, + "token_type": {"required": True}, + "token": {"required": True}, } _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Union[str, "TokenType"], + token_type: Union[str, "_models.TokenType"], token: str, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -128,9 +119,9 @@ def __init__( **kwargs ): """ - :keyword token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TokenType - :keyword token: Required. The access token used to access the source control provider. + :keyword token: The access token used to access the source control provider. Required. :paramtype token: str :keyword refresh_token: The refresh token used to refresh the access token. :paramtype refresh_token: str @@ -139,7 +130,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -147,10 +138,10 @@ def __init__( self.expires_in = expires_in -class AuthInfoUpdateParameters(msrest.serialization.Model): +class AuthInfoUpdateParameters(_serialization.Model): """The authorization properties for accessing the source code repository. - :ivar token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TokenType :ivar token: The access token used to access the source control provider. :vartype token: str @@ -163,17 +154,17 @@ class AuthInfoUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Optional[Union[str, "TokenType"]] = None, + token_type: Optional[Union[str, "_models.TokenType"]] = None, token: Optional[str] = None, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -181,7 +172,7 @@ def __init__( **kwargs ): """ - :keyword token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TokenType :keyword token: The access token used to access the source control provider. :paramtype token: str @@ -192,7 +183,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfoUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -200,11 +191,10 @@ def __init__( self.expires_in = expires_in -class BaseImageDependency(msrest.serialization.Model): +class BaseImageDependency(_serialization.Model): """Properties that describe a base image dependency. - :ivar type: The type of the base image dependency. Possible values include: "BuildTime", - "RunTime". + :ivar type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependencyType :ivar registry: The registry login server. :vartype registry: str @@ -217,17 +207,17 @@ class BaseImageDependency(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "BaseImageDependencyType"]] = None, + type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, registry: Optional[str] = None, repository: Optional[str] = None, tag: Optional[str] = None, @@ -235,7 +225,7 @@ def __init__( **kwargs ): """ - :keyword type: The type of the base image dependency. Possible values include: "BuildTime", + :keyword type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :paramtype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependencyType @@ -248,7 +238,7 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(BaseImageDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.registry = registry self.repository = repository @@ -256,106 +246,106 @@ def __init__( self.digest = digest -class BaseImageTrigger(msrest.serialization.Model): +class BaseImageTrigger(_serialization.Model): """The trigger based on base image dependency. All required parameters must be populated in order to send to Azure. - :ivar base_image_trigger_type: Required. The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. + Required. Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'base_image_trigger_type': {'required': True}, - 'name': {'required': True}, + "base_image_trigger_type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - base_image_trigger_type: Union[str, "BaseImageTriggerType"], + base_image_trigger_type: Union[str, "_models.BaseImageTriggerType"], name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword base_image_trigger_type: Required. The type of the auto trigger for base image - dependency updates. Possible values include: "All", "Runtime". + :keyword base_image_trigger_type: The type of the auto trigger for base image dependency + updates. Required. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.status = status self.name = name -class BaseImageTriggerUpdateParameters(msrest.serialization.Model): +class BaseImageTriggerUpdateParameters(_serialization.Model): """The properties for updating base image dependency trigger. All required parameters must be populated in order to send to Azure. :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime". + Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - base_image_trigger_type: Optional[Union[str, "BaseImageTriggerType"]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + base_image_trigger_type: Optional[Union[str, "_models.BaseImageTriggerType"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ :keyword base_image_trigger_type: The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + updates. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.status = status self.name = name -class Credentials(msrest.serialization.Model): +class Credentials(_serialization.Model): """The parameters that describes a set of credentials that will be used when a run is invoked. :ivar source_registry: Describes the credential parameters for accessing the source registry. @@ -370,15 +360,15 @@ class Credentials(msrest.serialization.Model): """ _attribute_map = { - 'source_registry': {'key': 'sourceRegistry', 'type': 'SourceRegistryCredentials'}, - 'custom_registries': {'key': 'customRegistries', 'type': '{CustomRegistryCredentials}'}, + "source_registry": {"key": "sourceRegistry", "type": "SourceRegistryCredentials"}, + "custom_registries": {"key": "customRegistries", "type": "{CustomRegistryCredentials}"}, } def __init__( self, *, - source_registry: Optional["SourceRegistryCredentials"] = None, - custom_registries: Optional[Dict[str, "CustomRegistryCredentials"]] = None, + source_registry: Optional["_models.SourceRegistryCredentials"] = None, + custom_registries: Optional[Dict[str, "_models.CustomRegistryCredentials"]] = None, **kwargs ): """ @@ -393,12 +383,12 @@ def __init__( :paramtype custom_registries: dict[str, ~azure.mgmt.containerregistry.v2018_09_01.models.CustomRegistryCredentials] """ - super(Credentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_registry = source_registry self.custom_registries = custom_registries -class CustomRegistryCredentials(msrest.serialization.Model): +class CustomRegistryCredentials(_serialization.Model): """Describes the credentials that will be used to access a custom registry during a run. :ivar user_name: The username for logging into the custom registry. @@ -409,15 +399,15 @@ class CustomRegistryCredentials(msrest.serialization.Model): """ _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'SecretObject'}, - 'password': {'key': 'password', 'type': 'SecretObject'}, + "user_name": {"key": "userName", "type": "SecretObject"}, + "password": {"key": "password", "type": "SecretObject"}, } def __init__( self, *, - user_name: Optional["SecretObject"] = None, - password: Optional["SecretObject"] = None, + user_name: Optional["_models.SecretObject"] = None, + password: Optional["_models.SecretObject"] = None, **kwargs ): """ @@ -427,22 +417,22 @@ def __init__( object that allows multiple ways of providing the value for it. :paramtype password: ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObject """ - super(CustomRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.password = password -class RunRequest(msrest.serialization.Model): +class RunRequest(_serialization.Model): """The request parameters for scheduling a run. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest 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 the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -450,42 +440,42 @@ class RunRequest(msrest.serialization.Model): """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } _subtype_map = { - 'type': {'DockerBuildRequest': 'DockerBuildRequest', 'EncodedTaskRunRequest': 'EncodedTaskRunRequest', 'FileTaskRunRequest': 'FileTaskRunRequest', 'TaskRunRequest': 'TaskRunRequest'} + "type": { + "DockerBuildRequest": "DockerBuildRequest", + "EncodedTaskRunRequest": "EncodedTaskRunRequest", + "FileTaskRunRequest": "FileTaskRunRequest", + "TaskRunRequest": "TaskRunRequest", + } } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, is_archive_enabled: bool = False, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool """ - super(RunRequest, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.is_archive_enabled = is_archive_enabled -class DockerBuildRequest(RunRequest): +class DockerBuildRequest(RunRequest): # pylint: disable=too-many-instance-attributes """The parameters for a docker quick build. 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 the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -497,7 +487,7 @@ class DockerBuildRequest(RunRequest): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source location. + :ivar docker_file_path: The Docker file path relative to the source location. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -505,7 +495,7 @@ class DockerBuildRequest(RunRequest): :vartype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties @@ -520,43 +510,43 @@ class DockerBuildRequest(RunRequest): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'docker_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True, "readonly": True}, + "docker_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, docker_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + arguments: Optional[List["_models.Argument"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ @@ -571,7 +561,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source location. + :keyword docker_file_path: The Docker file path relative to the source location. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -579,7 +569,7 @@ def __init__( :paramtype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -593,8 +583,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ - super(DockerBuildRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'DockerBuildRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "DockerBuildRequest" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -608,18 +598,18 @@ def __init__( self.credentials = credentials -class TaskStepProperties(msrest.serialization.Model): +class TaskStepProperties(_serialization.Model): """Base properties for any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStep, EncodedTaskStep, FileTaskStep. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStep, EncodedTaskStep, FileTaskStep 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 the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -632,28 +622,20 @@ class TaskStepProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'base_image_dependencies': {'readonly': True}, + "type": {"required": True, "readonly": True}, + "base_image_dependencies": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } - _subtype_map = { - 'type': {'Docker': 'DockerBuildStep', 'EncodedTask': 'EncodedTaskStep', 'FileTask': 'FileTaskStep'} - } + _subtype_map = {"type": {"Docker": "DockerBuildStep", "EncodedTask": "EncodedTaskStep", "FileTask": "FileTaskStep"}} - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -661,8 +643,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepProperties, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.base_image_dependencies = None self.context_path = context_path self.context_access_token = context_access_token @@ -675,8 +657,8 @@ class DockerBuildStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -693,7 +675,7 @@ class DockerBuildStep(TaskStepProperties): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source context. + :ivar docker_file_path: The Docker file path relative to the source context. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -703,22 +685,22 @@ class DockerBuildStep(TaskStepProperties): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'base_image_dependencies': {'readonly': True}, - 'docker_file_path': {'required': True}, + "type": {"required": True, "readonly": True}, + "base_image_dependencies": {"readonly": True}, + "docker_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, } def __init__( @@ -728,10 +710,10 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, **kwargs ): """ @@ -748,7 +730,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source context. + :keyword docker_file_path: The Docker file path relative to the source context. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -756,8 +738,8 @@ def __init__( step. :paramtype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] """ - super(DockerBuildStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -766,18 +748,18 @@ def __init__( self.arguments = arguments -class TaskStepUpdateParameters(msrest.serialization.Model): +class TaskStepUpdateParameters(_serialization.Model): """Base properties for updating any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters 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 the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -787,26 +769,24 @@ class TaskStepUpdateParameters(msrest.serialization.Model): """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } _subtype_map = { - 'type': {'Docker': 'DockerBuildStepUpdateParameters', 'EncodedTask': 'EncodedTaskStepUpdateParameters', 'FileTask': 'FileTaskStepUpdateParameters'} + "type": { + "Docker": "DockerBuildStepUpdateParameters", + "EncodedTask": "EncodedTaskStepUpdateParameters", + "FileTask": "FileTaskStepUpdateParameters", + } } - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -814,8 +794,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepUpdateParameters, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.context_path = context_path self.context_access_token = context_access_token @@ -827,8 +807,8 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -852,19 +832,19 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'target': {'key': 'target', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "target": {"key": "target", "type": "str"}, } def __init__( @@ -876,7 +856,7 @@ def __init__( is_push_enabled: Optional[bool] = None, no_cache: Optional[bool] = None, docker_file_path: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, target: Optional[str] = None, **kwargs ): @@ -902,8 +882,8 @@ def __init__( :keyword target: The name of the target build stage for the docker build. :paramtype target: str """ - super(DockerBuildStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -919,13 +899,13 @@ class EncodedTaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -933,7 +913,7 @@ class EncodedTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties @@ -948,45 +928,45 @@ class EncodedTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'encoded_task_content': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True, "readonly": True}, + "encoded_task_content": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, encoded_task_content: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str @@ -994,7 +974,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -1008,8 +988,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ - super(EncodedTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'EncodedTaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "EncodedTaskRunRequest" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1027,8 +1007,8 @@ class EncodedTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1038,8 +1018,8 @@ class EncodedTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -1048,19 +1028,19 @@ class EncodedTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'base_image_dependencies': {'readonly': True}, - 'encoded_task_content': {'required': True}, + "type": {"required": True, "readonly": True}, + "base_image_dependencies": {"readonly": True}, + "encoded_task_content": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1070,7 +1050,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1079,16 +1059,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ - super(EncodedTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1101,8 +1081,8 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1118,16 +1098,16 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1137,7 +1117,7 @@ def __init__( context_access_token: Optional[str] = None, encoded_task_content: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1153,8 +1133,8 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ - super(EncodedTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1167,12 +1147,12 @@ class FileTaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar task_file_path: Required. The template/definition file path relative to the source. + :ivar task_file_path: The template/definition file path relative to the source. Required. :vartype task_file_path: str :ivar values_file_path: The values/parameters file path relative to the source. :vartype values_file_path: str @@ -1180,7 +1160,7 @@ class FileTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties @@ -1195,44 +1175,44 @@ class FileTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'task_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True, "readonly": True}, + "task_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, task_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword task_file_path: Required. The template/definition file path relative to the source. + :keyword task_file_path: The template/definition file path relative to the source. Required. :paramtype task_file_path: str :keyword values_file_path: The values/parameters file path relative to the source. :paramtype values_file_path: str @@ -1240,7 +1220,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -1254,8 +1234,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ - super(FileTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'FileTaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "FileTaskRunRequest" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1273,8 +1253,8 @@ class FileTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1284,8 +1264,8 @@ class FileTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar task_file_path: Required. The task template/definition file path relative to the source - context. + :ivar task_file_path: The task template/definition file path relative to the source context. + Required. :vartype task_file_path: str :ivar values_file_path: The task values/parameters file path relative to the source context. :vartype values_file_path: str @@ -1294,19 +1274,19 @@ class FileTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'base_image_dependencies': {'readonly': True}, - 'task_file_path': {'required': True}, + "type": {"required": True, "readonly": True}, + "base_image_dependencies": {"readonly": True}, + "task_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1316,7 +1296,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1325,16 +1305,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword task_file_path: Required. The task template/definition file path relative to the - source context. + :keyword task_file_path: The task template/definition file path relative to the source context. + Required. :paramtype task_file_path: str :keyword values_file_path: The task values/parameters file path relative to the source context. :paramtype values_file_path: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ - super(FileTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1347,8 +1327,8 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1364,16 +1344,16 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True, 'readonly': True}, + "type": {"required": True, "readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1383,7 +1363,7 @@ def __init__( context_access_token: Optional[str] = None, task_file_path: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1399,14 +1379,14 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ - super(FileTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values -class ImageDescriptor(msrest.serialization.Model): +class ImageDescriptor(_serialization.Model): """Properties for a registry image. :ivar registry: The registry login server. @@ -1420,10 +1400,10 @@ class ImageDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( @@ -1445,14 +1425,14 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(ImageDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry = registry self.repository = repository self.tag = tag self.digest = digest -class ImageUpdateTrigger(msrest.serialization.Model): +class ImageUpdateTrigger(_serialization.Model): """The image update trigger that caused a build. :ivar id: The unique ID of the trigger. @@ -1464,17 +1444,17 @@ class ImageUpdateTrigger(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'images': {'key': 'images', 'type': '[ImageDescriptor]'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "images": {"key": "images", "type": "[ImageDescriptor]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, - images: Optional[List["ImageDescriptor"]] = None, + images: Optional[List["_models.ImageDescriptor"]] = None, **kwargs ): """ @@ -1485,101 +1465,101 @@ def __init__( :keyword images: The list of image updates that caused the build. :paramtype images: list[~azure.mgmt.containerregistry.v2018_09_01.models.ImageDescriptor] """ - super(ImageUpdateTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.images = images -class PlatformProperties(msrest.serialization.Model): +class PlatformProperties(_serialization.Model): """The platform properties against which the run has to happen. All required parameters must be populated in order to send to Azure. - :ivar os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :ivar os: The operating system type required for the run. Required. Known values are: "Windows" + and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2018_09_01.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :vartype architecture: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant """ _validation = { - 'os': {'required': True}, + "os": {"required": True}, } _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Union[str, "OS"], - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Union[str, "_models.OS"], + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Required. Known values are: + "Windows" and "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2018_09_01.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant """ - super(PlatformProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class PlatformUpdateParameters(msrest.serialization.Model): +class PlatformUpdateParameters(_serialization.Model): """The properties for updating the platform configuration. - :ivar os: The operating system type required for the run. Possible values include: "Windows", + :ivar os: The operating system type required for the run. Known values are: "Windows" and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2018_09_01.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :vartype architecture: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant """ _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Optional[Union[str, "OS"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Optional[Union[str, "_models.OS"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Known values are: "Windows" and + "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2018_09_01.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant """ - super(PlatformUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -1593,30 +1573,26 @@ class ProxyResource(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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1629,43 +1605,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1673,7 +1643,7 @@ def __init__( self.tags = tags -class Run(ProxyResource): +class Run(ProxyResource): # pylint: disable=too-many-instance-attributes """Run resource properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1686,13 +1656,13 @@ class Run(ProxyResource): :vartype type: str :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunStatus :ivar last_updated_time: The last updated time for the run. :vartype last_updated_time: ~datetime.datetime - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunType :ivar create_time: The time the run was scheduled. :vartype create_time: ~datetime.datetime @@ -1724,8 +1694,8 @@ class Run(ProxyResource): :ivar run_error_message: The error message received from backend systems after the run is scheduled. :vartype run_error_message: str - :ivar provisioning_state: The provisioning state of a run. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_09_01.models.ProvisioningState :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -1733,68 +1703,68 @@ class Run(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'run_error_message': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "run_error_message": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'run_id': {'key': 'properties.runId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'run_type': {'key': 'properties.runType', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'properties.finishTime', 'type': 'iso-8601'}, - 'output_images': {'key': 'properties.outputImages', 'type': '[ImageDescriptor]'}, - 'task': {'key': 'properties.task', 'type': 'str'}, - 'image_update_trigger': {'key': 'properties.imageUpdateTrigger', 'type': 'ImageUpdateTrigger'}, - 'source_trigger': {'key': 'properties.sourceTrigger', 'type': 'SourceTriggerDescriptor'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'source_registry_auth': {'key': 'properties.sourceRegistryAuth', 'type': 'str'}, - 'custom_registries': {'key': 'properties.customRegistries', 'type': '[str]'}, - 'run_error_message': {'key': 'properties.runErrorMessage', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_archive_enabled': {'key': 'properties.isArchiveEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "run_id": {"key": "properties.runId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "run_type": {"key": "properties.runType", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "finish_time": {"key": "properties.finishTime", "type": "iso-8601"}, + "output_images": {"key": "properties.outputImages", "type": "[ImageDescriptor]"}, + "task": {"key": "properties.task", "type": "str"}, + "image_update_trigger": {"key": "properties.imageUpdateTrigger", "type": "ImageUpdateTrigger"}, + "source_trigger": {"key": "properties.sourceTrigger", "type": "SourceTriggerDescriptor"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "source_registry_auth": {"key": "properties.sourceRegistryAuth", "type": "str"}, + "custom_registries": {"key": "properties.customRegistries", "type": "[str]"}, + "run_error_message": {"key": "properties.runErrorMessage", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_archive_enabled": {"key": "properties.isArchiveEnabled", "type": "bool"}, } def __init__( self, *, run_id: Optional[str] = None, - status: Optional[Union[str, "RunStatus"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, last_updated_time: Optional[datetime.datetime] = None, - run_type: Optional[Union[str, "RunType"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, create_time: Optional[datetime.datetime] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - output_images: Optional[List["ImageDescriptor"]] = None, + output_images: Optional[List["_models.ImageDescriptor"]] = None, task: Optional[str] = None, - image_update_trigger: Optional["ImageUpdateTrigger"] = None, - source_trigger: Optional["SourceTriggerDescriptor"] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, + image_update_trigger: Optional["_models.ImageUpdateTrigger"] = None, + source_trigger: Optional["_models.SourceTriggerDescriptor"] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, source_registry_auth: Optional[str] = None, custom_registries: Optional[List[str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - is_archive_enabled: Optional[bool] = False, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + is_archive_enabled: bool = False, **kwargs ): """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunStatus :keyword last_updated_time: The last updated time for the run. :paramtype last_updated_time: ~datetime.datetime - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunType :keyword create_time: The time the run was scheduled. :paramtype create_time: ~datetime.datetime @@ -1825,14 +1795,14 @@ def __init__( :paramtype source_registry_auth: str :keyword custom_registries: The list of custom registries that were logged in during this run. :paramtype custom_registries: list[str] - :keyword provisioning_state: The provisioning state of a run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :keyword provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :paramtype provisioning_state: str or ~azure.mgmt.containerregistry.v2018_09_01.models.ProvisioningState :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(Run, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.status = status self.last_updated_time = last_updated_time @@ -1853,16 +1823,16 @@ def __init__( self.is_archive_enabled = is_archive_enabled -class RunFilter(msrest.serialization.Model): +class RunFilter(_serialization.Model): """Properties that are enabled for Odata querying on runs. :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunType - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunStatus :ivar create_time: The create time for a run. :vartype create_time: ~datetime.datetime @@ -1879,22 +1849,22 @@ class RunFilter(msrest.serialization.Model): """ _attribute_map = { - 'run_id': {'key': 'runId', 'type': 'str'}, - 'run_type': {'key': 'runType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'create_time': {'key': 'createTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'output_image_manifests': {'key': 'outputImageManifests', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, + "run_id": {"key": "runId", "type": "str"}, + "run_type": {"key": "runType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "create_time": {"key": "createTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "output_image_manifests": {"key": "outputImageManifests", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_name": {"key": "taskName", "type": "str"}, } def __init__( self, *, run_id: Optional[str] = None, - run_type: Optional[Union[str, "RunType"]] = None, - status: Optional[Union[str, "RunStatus"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, create_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, output_image_manifests: Optional[str] = None, @@ -1905,11 +1875,11 @@ def __init__( """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunType - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.RunStatus :keyword create_time: The create time for a run. :paramtype create_time: ~datetime.datetime @@ -1924,7 +1894,7 @@ def __init__( :keyword task_name: The name of the task that the run corresponds to. :paramtype task_name: str """ - super(RunFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.run_type = run_type self.status = status @@ -1935,7 +1905,7 @@ def __init__( self.task_name = task_name -class RunGetLogResult(msrest.serialization.Model): +class RunGetLogResult(_serialization.Model): """The result of get log link operation. :ivar log_link: The link to logs for a run on a azure container registry. @@ -1943,24 +1913,19 @@ class RunGetLogResult(msrest.serialization.Model): """ _attribute_map = { - 'log_link': {'key': 'logLink', 'type': 'str'}, + "log_link": {"key": "logLink", "type": "str"}, } - def __init__( - self, - *, - log_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, log_link: Optional[str] = None, **kwargs): """ :keyword log_link: The link to logs for a run on a azure container registry. :paramtype log_link: str """ - super(RunGetLogResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_link = log_link -class RunListResult(msrest.serialization.Model): +class RunListResult(_serialization.Model): """Collection of runs. :ivar value: The collection value. @@ -1970,29 +1935,23 @@ class RunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Run]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Run]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Run"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Run"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2018_09_01.models.Run] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(RunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RunUpdateParameters(msrest.serialization.Model): +class RunUpdateParameters(_serialization.Model): """The set of run properties that can be updated. :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -2000,24 +1959,19 @@ class RunUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(RunUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_archive_enabled = is_archive_enabled -class SecretObject(msrest.serialization.Model): +class SecretObject(_serialization.Model): """Describes the properties of a secret object value. :ivar value: The value of the secret. The format of this value will be determined @@ -2026,21 +1980,17 @@ class SecretObject(msrest.serialization.Model): :vartype value: str :ivar type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque". + interpreted. "Opaque" :vartype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObjectType """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( - self, - *, - value: Optional[str] = None, - type: Optional[Union[str, "SecretObjectType"]] = None, - **kwargs + self, *, value: Optional[str] = None, type: Optional[Union[str, "_models.SecretObjectType"]] = None, **kwargs ): """ :keyword value: The value of the secret. The format of this value will be determined @@ -2049,70 +1999,63 @@ def __init__( :paramtype value: str :keyword type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque". + interpreted. "Opaque" :paramtype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObjectType """ - super(SecretObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.type = type -class SetValue(msrest.serialization.Model): +class SetValue(_serialization.Model): """The properties of a overridable value that can be passed to a task template. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the overridable value. + :ivar name: The name of the overridable value. Required. :vartype name: str - :ivar value: Required. The overridable value. + :ivar value: The overridable value. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the value represents a secret or not. :vartype is_secret: bool """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the overridable value. + :keyword name: The name of the overridable value. Required. :paramtype name: str - :keyword value: Required. The overridable value. + :keyword value: The overridable value. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the value represents a secret or not. :paramtype is_secret: bool """ - super(SetValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class SourceProperties(msrest.serialization.Model): +class SourceProperties(_serialization.Model): """The properties of the source code repository. All required parameters must be populated in order to send to Azure. - :ivar source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceControlType - :ivar repository_url: Required. The full URL to the source code repository. + :ivar repository_url: The full URL to the source code repository. Required. :vartype repository_url: str :ivar branch: The branch name of the source code. :vartype branch: str @@ -2124,32 +2067,32 @@ class SourceProperties(msrest.serialization.Model): """ _validation = { - 'source_control_type': {'required': True}, - 'repository_url': {'required': True}, + "source_control_type": {"required": True}, + "repository_url": {"required": True}, } _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfo'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfo"}, } def __init__( self, *, - source_control_type: Union[str, "SourceControlType"], + source_control_type: Union[str, "_models.SourceControlType"], repository_url: str, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfo"] = None, + source_control_auth_properties: Optional["_models.AuthInfo"] = None, **kwargs ): """ - :keyword source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceControlType - :keyword repository_url: Required. The full URL to the source code repository. + :keyword repository_url: The full URL to the source code repository. Required. :paramtype repository_url: str :keyword branch: The branch name of the source code. :paramtype branch: str @@ -2159,104 +2102,99 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfo """ - super(SourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceRegistryCredentials(msrest.serialization.Model): +class SourceRegistryCredentials(_serialization.Model): """Describes the credential parameters for accessing the source registry. :ivar login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :vartype login_mode: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceRegistryLoginMode """ _attribute_map = { - 'login_mode': {'key': 'loginMode', 'type': 'str'}, + "login_mode": {"key": "loginMode", "type": "str"}, } - def __init__( - self, - *, - login_mode: Optional[Union[str, "SourceRegistryLoginMode"]] = None, - **kwargs - ): + def __init__(self, *, login_mode: Optional[Union[str, "_models.SourceRegistryLoginMode"]] = None, **kwargs): """ :keyword login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :paramtype login_mode: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceRegistryLoginMode """ - super(SourceRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.login_mode = login_mode -class SourceTrigger(msrest.serialization.Model): +class SourceTrigger(_serialization.Model): """The properties of a source based trigger. All required parameters must be populated in order to send to Azure. - :ivar source_repository: Required. The properties that describes the source(code) for the task. + :ivar source_repository: The properties that describes the source(code) for the task. Required. :vartype source_repository: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceProperties - :ivar source_trigger_events: Required. The source event corresponding to the trigger. + :ivar source_trigger_events: The source event corresponding to the trigger. Required. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'source_repository': {'required': True}, - 'source_trigger_events': {'required': True}, - 'name': {'required': True}, + "source_repository": {"required": True}, + "source_trigger_events": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceProperties'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceProperties"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - source_repository: "SourceProperties", - source_trigger_events: List[Union[str, "SourceTriggerEvent"]], + source_repository: "_models.SourceProperties", + source_trigger_events: List[Union[str, "_models.SourceTriggerEvent"]], name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword source_repository: Required. The properties that describes the source(code) for the - task. + :keyword source_repository: The properties that describes the source(code) for the task. + Required. :paramtype source_repository: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceProperties - :keyword source_trigger_events: Required. The source event corresponding to the trigger. + :keyword source_trigger_events: The source event corresponding to the trigger. Required. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceTriggerDescriptor(msrest.serialization.Model): +class SourceTriggerDescriptor(_serialization.Model): """The source trigger that caused a run. :ivar id: The unique ID of the trigger. @@ -2276,19 +2214,19 @@ class SourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_type': {'key': 'eventType', 'type': 'str'}, - 'commit_id': {'key': 'commitId', 'type': 'str'}, - 'pull_request_id': {'key': 'pullRequestId', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch_name': {'key': 'branchName', 'type': 'str'}, - 'provider_type': {'key': 'providerType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "event_type": {"key": "eventType", "type": "str"}, + "commit_id": {"key": "commitId", "type": "str"}, + "pull_request_id": {"key": "pullRequestId", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch_name": {"key": "branchName", "type": "str"}, + "provider_type": {"key": "providerType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin event_type: Optional[str] = None, commit_id: Optional[str] = None, pull_request_id: Optional[str] = None, @@ -2313,7 +2251,7 @@ def __init__( :keyword provider_type: The source control provider type. :paramtype provider_type: str """ - super(SourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.event_type = event_type self.commit_id = commit_id @@ -2323,7 +2261,7 @@ def __init__( self.provider_type = provider_type -class SourceTriggerUpdateParameters(msrest.serialization.Model): +class SourceTriggerUpdateParameters(_serialization.Model): """The properties for updating a source based trigger. All required parameters must be populated in order to send to Azure. @@ -2334,30 +2272,30 @@ class SourceTriggerUpdateParameters(msrest.serialization.Model): :ivar source_trigger_events: The source event corresponding to the trigger. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceUpdateParameters'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceUpdateParameters"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - source_repository: Optional["SourceUpdateParameters"] = None, - source_trigger_events: Optional[List[Union[str, "SourceTriggerEvent"]]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + source_repository: Optional["_models.SourceUpdateParameters"] = None, + source_trigger_events: Optional[List[Union[str, "_models.SourceTriggerEvent"]]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ @@ -2367,23 +2305,23 @@ def __init__( :keyword source_trigger_events: The source event corresponding to the trigger. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceUpdateParameters(msrest.serialization.Model): +class SourceUpdateParameters(_serialization.Model): """The properties for updating the source code repository. - :ivar source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Known values are: "Github" and + "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceControlType :ivar repository_url: The full URL to the source code repository. @@ -2398,24 +2336,24 @@ class SourceUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfoUpdateParameters'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfoUpdateParameters"}, } def __init__( self, *, - source_control_type: Optional[Union[str, "SourceControlType"]] = None, + source_control_type: Optional[Union[str, "_models.SourceControlType"]] = None, repository_url: Optional[str] = None, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfoUpdateParameters"] = None, + source_control_auth_properties: Optional["_models.AuthInfoUpdateParameters"] = None, **kwargs ): """ - :keyword source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Known values are: "Github" + and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SourceControlType :keyword repository_url: The full URL to the source code repository. @@ -2428,14 +2366,14 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfoUpdateParameters """ - super(SourceUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceUploadDefinition(msrest.serialization.Model): +class SourceUploadDefinition(_serialization.Model): """The properties of a response to source upload request. :ivar upload_url: The URL where the client can upload the source. @@ -2446,17 +2384,11 @@ class SourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } - def __init__( - self, - *, - upload_url: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, upload_url: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword upload_url: The URL where the client can upload the source. :paramtype upload_url: str @@ -2464,78 +2396,78 @@ def __init__( queue build request. :paramtype relative_path: str """ - super(SourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.upload_url = upload_url self.relative_path = relative_path -class Task(Resource): - """The task that has the ARM resource and task properties. -The task will have all information to schedule a run against it. - - 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: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. - :vartype location: str - :ivar tags: A set of tags. The tags of the resource. - :vartype tags: dict[str, str] - :ivar provisioning_state: The provisioning state of the task. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2018_09_01.models.ProvisioningState - :ivar creation_date: The creation date of task. - :vartype creation_date: ~datetime.datetime - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStatus - :ivar platform: The platform properties against which the run has to happen. - :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties - :ivar agent_configuration: The machine configuration of the run agent. - :vartype agent_configuration: ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :ivar step: The properties of a task step. - :vartype step: ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStepProperties - :ivar trigger: The properties that describe all triggers for the task. - :vartype trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerProperties - :ivar credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :vartype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials +class Task(Resource): # pylint: disable=too-many-instance-attributes + """The task that has the ARM resource and task properties. + The task will have all information to schedule a run against it. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar provisioning_state: The provisioning state of the task. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2018_09_01.models.ProvisioningState + :ivar creation_date: The creation date of task. + :vartype creation_date: ~datetime.datetime + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStatus + :ivar platform: The platform properties against which the run has to happen. + :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties + :ivar agent_configuration: The machine configuration of the run agent. + :vartype agent_configuration: ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties + :ivar timeout: Run timeout in seconds. + :vartype timeout: int + :ivar step: The properties of a task step. + :vartype step: ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStepProperties + :ivar trigger: The properties that describe all triggers for the task. + :vartype trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerProperties + :ivar credentials: The properties that describes a set of credentials that will be used when + this run is invoked. + :vartype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "creation_date": {"readonly": True}, + "timeout": {"maximum": 28800, "minimum": 300}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerProperties'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepProperties"}, + "trigger": {"key": "properties.trigger", "type": "TriggerProperties"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, } def __init__( @@ -2543,22 +2475,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, - timeout: Optional[int] = 3600, - step: Optional["TaskStepProperties"] = None, - trigger: Optional["TriggerProperties"] = None, - credentials: Optional["Credentials"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, + timeout: int = 3600, + step: Optional["_models.TaskStepProperties"] = None, + trigger: Optional["_models.TriggerProperties"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties @@ -2575,7 +2507,7 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ - super(Task, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.creation_date = None self.status = status @@ -2587,7 +2519,7 @@ def __init__( self.credentials = credentials -class TaskListResult(msrest.serialization.Model): +class TaskListResult(_serialization.Model): """The collection of tasks. :ivar value: The collection value. @@ -2597,24 +2529,18 @@ class TaskListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Task]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Task]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Task"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Task"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2018_09_01.models.Task] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(TaskListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2626,58 +2552,58 @@ class TaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar task_name: Required. The name of task against which run has to be queued. + :ivar task_name: The name of task against which run has to be queued. Required. :vartype task_name: str :ivar values: The collection of overridable values that can be passed when running a task. :vartype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ _validation = { - 'type': {'required': True, 'readonly': True}, - 'task_name': {'required': True}, + "type": {"required": True, "readonly": True}, + "task_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_name": {"key": "taskName", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( self, *, task_name: str, - is_archive_enabled: Optional[bool] = False, - values: Optional[List["SetValue"]] = None, + is_archive_enabled: bool = False, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword task_name: Required. The name of task against which run has to be queued. + :keyword task_name: The name of task against which run has to be queued. Required. :paramtype task_name: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2018_09_01.models.SetValue] """ - super(TaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'TaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "TaskRunRequest" self.task_name = task_name self.values = values -class TaskUpdateParameters(msrest.serialization.Model): +class TaskUpdateParameters(_serialization.Model): """The parameters for updating a task. - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStatus :ivar platform: The platform properties against which the run has to happen. :vartype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformUpdateParameters @@ -2695,33 +2621,33 @@ class TaskUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformUpdateParameters'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepUpdateParameters'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerUpdateParameters'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, + "tags": {"key": "tags", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformUpdateParameters"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepUpdateParameters"}, + "trigger": {"key": "properties.trigger", "type": "TriggerUpdateParameters"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformUpdateParameters"] = None, - agent_configuration: Optional["AgentProperties"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformUpdateParameters"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, timeout: Optional[int] = None, - step: Optional["TaskStepUpdateParameters"] = None, - trigger: Optional["TriggerUpdateParameters"] = None, - credentials: Optional["Credentials"] = None, + step: Optional["_models.TaskStepUpdateParameters"] = None, + trigger: Optional["_models.TriggerUpdateParameters"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformUpdateParameters @@ -2738,7 +2664,7 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials """ - super(TaskUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.status = status self.platform = platform @@ -2749,7 +2675,7 @@ def __init__( self.credentials = credentials -class TriggerProperties(msrest.serialization.Model): +class TriggerProperties(_serialization.Model): """The properties of a trigger. :ivar source_triggers: The collection of triggers based on source code repository. @@ -2759,15 +2685,15 @@ class TriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTrigger]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTrigger'}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTrigger]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTrigger"}, } def __init__( self, *, - source_triggers: Optional[List["SourceTrigger"]] = None, - base_image_trigger: Optional["BaseImageTrigger"] = None, + source_triggers: Optional[List["_models.SourceTrigger"]] = None, + base_image_trigger: Optional["_models.BaseImageTrigger"] = None, **kwargs ): """ @@ -2778,12 +2704,12 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTrigger """ - super(TriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger -class TriggerUpdateParameters(msrest.serialization.Model): +class TriggerUpdateParameters(_serialization.Model): """The properties for updating triggers. :ivar source_triggers: The collection of triggers based on source code repository. @@ -2795,15 +2721,15 @@ class TriggerUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTriggerUpdateParameters]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTriggerUpdateParameters'}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTriggerUpdateParameters]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTriggerUpdateParameters"}, } def __init__( self, *, - source_triggers: Optional[List["SourceTriggerUpdateParameters"]] = None, - base_image_trigger: Optional["BaseImageTriggerUpdateParameters"] = None, + source_triggers: Optional[List["_models.SourceTriggerUpdateParameters"]] = None, + base_image_trigger: Optional["_models.BaseImageTriggerUpdateParameters"] = None, **kwargs ): """ @@ -2814,6 +2740,6 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerUpdateParameters """ - super(TriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/__init__.py index bb338b8a913c..d0afbe0f997d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._runs_operations import RunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'RunsOperations', - 'TasksOperations', + "RegistriesOperations", + "RunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_registries_operations.py index 0d81837f6812..1ea577f28fce 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_registries_operations.py @@ -6,164 +6,174 @@ # 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, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_schedule_run_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_schedule_run_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_build_source_upload_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class RegistriesOperations(object): - """RegistriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -172,33 +182,39 @@ def _schedule_run_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace + @overload def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest + :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 @@ -209,17 +225,82 @@ def begin_schedule_run( Retry-After header is present. :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest 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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._schedule_run_initial( resource_group_name=resource_group_name, @@ -227,88 +308,97 @@ def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_runs_operations.py index 29e167bf6ccd..a4dcc5ea2fc3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_runs_operations.py @@ -6,246 +6,237 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, registry_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_log_sas_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any +def build_cancel_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) - -class RunsOperations(object): - """RunsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -255,13 +246,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.RunListResult"]: + ) -> Iterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -271,43 +262,53 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Run or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -318,16 +319,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,112 +336,127 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -450,18 +464,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -469,21 +561,25 @@ def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters 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 @@ -494,17 +590,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -513,128 +609,138 @@ def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -644,25 +750,20 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace - def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_cancel(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> LROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -674,42 +775,48 @@ def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_tasks_operations.py index 3fbcf56852b3..c7017a7a7809 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_tasks_operations.py @@ -6,334 +6,330 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_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, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_details_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TasksOperations(object): - """TasksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2018_09_01.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Task or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -344,16 +340,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -363,112 +357,127 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -476,18 +485,95 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task + :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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -495,20 +581,24 @@ def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task 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 @@ -519,17 +609,17 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -538,65 +628,72 @@ def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -606,25 +703,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -636,83 +730,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -720,18 +834,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -739,21 +931,25 @@ def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters 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 @@ -764,17 +960,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2018_09_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -783,92 +979,98 @@ def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get_details(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_configuration.py index ede2b544b4c1..fdabffb18a6a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-04-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", "2019-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_container_registry_management_client.py index bf1fb405631f..6a1d846ea019 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, RunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -31,9 +31,9 @@ class ContainerRegistryManagementClient: :vartype runs: azure.mgmt.containerregistry.v2019_04_01.operations.RunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2019_04_01.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -51,10 +51,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -62,12 +64,7 @@ def __init__( self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -76,7 +73,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 @@ -89,15 +86,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_metadata.json index c6887fe2db0c..ff7ee888cef7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -101,4 +101,4 @@ "runs": "RunsOperations", "tasks": "TasksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_configuration.py index 18dedd22b9a0..c9f59bd08681 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-04-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", "2019-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_container_registry_management_client.py index cadd28063a15..2d1908d2b8ef 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, RunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -32,9 +32,9 @@ class ContainerRegistryManagementClient: :vartype runs: azure.mgmt.containerregistry.v2019_04_01.aio.operations.RunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2019_04_01.aio.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,10 +52,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -63,12 +65,7 @@ def __init__( self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -77,7 +74,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/__init__.py index bb338b8a913c..d0afbe0f997d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._runs_operations import RunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'RunsOperations', - 'TasksOperations', + "RegistriesOperations", + "RunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_registries_operations.py index 96c7dd2ba666..9a4ad70dd524 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_registries_operations.py @@ -6,80 +6,102 @@ # 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, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request_initial -T = TypeVar('T') +from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -88,33 +110,39 @@ async def _schedule_run_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace_async + @overload async def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest + :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 @@ -126,17 +154,84 @@ async def begin_schedule_run( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._schedule_run_initial( resource_group_name=resource_group_name, @@ -144,88 +239,97 @@ async def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace_async async def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_runs_operations.py index 739e54b21a76..3baa7cd46761 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_runs_operations.py @@ -6,46 +6,65 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._runs_operations import build_cancel_request_initial, build_get_log_sas_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._runs_operations import ( + build_cancel_request, + build_get_log_sas_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RunsOperations: - """RunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.aio.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -55,13 +74,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.RunListResult"]: + ) -> AsyncIterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -71,43 +90,54 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) + :return: An iterator like instance of either Run or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +148,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,112 +165,127 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + async def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -250,18 +293,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -269,21 +392,25 @@ async def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters 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 @@ -295,17 +422,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -314,128 +441,138 @@ async def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace_async async def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } async def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -445,25 +582,22 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace_async - async def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + async def begin_cancel( + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -475,42 +609,48 @@ async def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_tasks_operations.py index 2acf66505dd0..e642436a01a4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_tasks_operations.py @@ -6,95 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tasks_operations import build_create_request_initial, build_delete_request_initial, build_get_details_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tasks_operations import ( + build_create_request, + build_delete_request, + build_get_details_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TasksOperations: - """TasksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.aio.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) + :return: An iterator like instance of either Task or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +150,127 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + async def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +278,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,20 +376,24 @@ async def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task 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 @@ -281,17 +405,17 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -300,65 +424,72 @@ async def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -368,25 +499,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -398,83 +526,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -482,18 +630,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -501,21 +729,25 @@ async def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters 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 @@ -527,17 +759,17 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -546,92 +778,100 @@ async def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async async def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any + ) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/__init__.py index 4f5b31cf9f37..5faf05f60128 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/__init__.py @@ -59,95 +59,97 @@ from ._models_py3 import TriggerUpdateParameters from ._models_py3 import UserIdentityProperties - -from ._container_registry_management_client_enums import ( - Architecture, - BaseImageDependencyType, - BaseImageTriggerType, - OS, - ProvisioningState, - ResourceIdentityType, - RunStatus, - RunType, - SecretObjectType, - SourceControlType, - SourceRegistryLoginMode, - SourceTriggerEvent, - StepType, - TaskStatus, - TokenType, - TriggerStatus, - Variant, -) +from ._container_registry_management_client_enums import Architecture +from ._container_registry_management_client_enums import BaseImageDependencyType +from ._container_registry_management_client_enums import BaseImageTriggerType +from ._container_registry_management_client_enums import OS +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import RunStatus +from ._container_registry_management_client_enums import RunType +from ._container_registry_management_client_enums import SecretObjectType +from ._container_registry_management_client_enums import SourceControlType +from ._container_registry_management_client_enums import SourceRegistryLoginMode +from ._container_registry_management_client_enums import SourceTriggerEvent +from ._container_registry_management_client_enums import StepType +from ._container_registry_management_client_enums import TaskStatus +from ._container_registry_management_client_enums import TokenType +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import Variant +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AgentProperties', - 'Argument', - 'AuthInfo', - 'AuthInfoUpdateParameters', - 'BaseImageDependency', - 'BaseImageTrigger', - 'BaseImageTriggerUpdateParameters', - 'Credentials', - 'CustomRegistryCredentials', - 'DockerBuildRequest', - 'DockerBuildStep', - 'DockerBuildStepUpdateParameters', - 'EncodedTaskRunRequest', - 'EncodedTaskStep', - 'EncodedTaskStepUpdateParameters', - 'FileTaskRunRequest', - 'FileTaskStep', - 'FileTaskStepUpdateParameters', - 'IdentityProperties', - 'ImageDescriptor', - 'ImageUpdateTrigger', - 'PlatformProperties', - 'PlatformUpdateParameters', - 'ProxyResource', - 'Resource', - 'Run', - 'RunFilter', - 'RunGetLogResult', - 'RunListResult', - 'RunRequest', - 'RunUpdateParameters', - 'SecretObject', - 'SetValue', - 'SourceProperties', - 'SourceRegistryCredentials', - 'SourceTrigger', - 'SourceTriggerDescriptor', - 'SourceTriggerUpdateParameters', - 'SourceUpdateParameters', - 'SourceUploadDefinition', - 'Task', - 'TaskListResult', - 'TaskRunRequest', - 'TaskStepProperties', - 'TaskStepUpdateParameters', - 'TaskUpdateParameters', - 'TimerTrigger', - 'TimerTriggerDescriptor', - 'TimerTriggerUpdateParameters', - 'TriggerProperties', - 'TriggerUpdateParameters', - 'UserIdentityProperties', - 'Architecture', - 'BaseImageDependencyType', - 'BaseImageTriggerType', - 'OS', - 'ProvisioningState', - 'ResourceIdentityType', - 'RunStatus', - 'RunType', - 'SecretObjectType', - 'SourceControlType', - 'SourceRegistryLoginMode', - 'SourceTriggerEvent', - 'StepType', - 'TaskStatus', - 'TokenType', - 'TriggerStatus', - 'Variant', + "AgentProperties", + "Argument", + "AuthInfo", + "AuthInfoUpdateParameters", + "BaseImageDependency", + "BaseImageTrigger", + "BaseImageTriggerUpdateParameters", + "Credentials", + "CustomRegistryCredentials", + "DockerBuildRequest", + "DockerBuildStep", + "DockerBuildStepUpdateParameters", + "EncodedTaskRunRequest", + "EncodedTaskStep", + "EncodedTaskStepUpdateParameters", + "FileTaskRunRequest", + "FileTaskStep", + "FileTaskStepUpdateParameters", + "IdentityProperties", + "ImageDescriptor", + "ImageUpdateTrigger", + "PlatformProperties", + "PlatformUpdateParameters", + "ProxyResource", + "Resource", + "Run", + "RunFilter", + "RunGetLogResult", + "RunListResult", + "RunRequest", + "RunUpdateParameters", + "SecretObject", + "SetValue", + "SourceProperties", + "SourceRegistryCredentials", + "SourceTrigger", + "SourceTriggerDescriptor", + "SourceTriggerUpdateParameters", + "SourceUpdateParameters", + "SourceUploadDefinition", + "Task", + "TaskListResult", + "TaskRunRequest", + "TaskStepProperties", + "TaskStepUpdateParameters", + "TaskUpdateParameters", + "TimerTrigger", + "TimerTriggerDescriptor", + "TimerTriggerUpdateParameters", + "TriggerProperties", + "TriggerUpdateParameters", + "UserIdentityProperties", + "Architecture", + "BaseImageDependencyType", + "BaseImageTriggerType", + "OS", + "ProvisioningState", + "ResourceIdentityType", + "RunStatus", + "RunType", + "SecretObjectType", + "SourceControlType", + "SourceRegistryLoginMode", + "SourceTriggerEvent", + "StepType", + "TaskStatus", + "TokenType", + "TriggerStatus", + "Variant", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_container_registry_management_client_enums.py index f0aecff21d00..ec24791fa1a7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_container_registry_management_client_enums.py @@ -7,42 +7,40 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The OS architecture. - """ +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS architecture.""" AMD64 = "amd64" X86 = "x86" ARM = "arm" -class BaseImageDependencyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the base image dependency. - """ + +class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the base image dependency.""" BUILD_TIME = "BuildTime" RUN_TIME = "RunTime" -class BaseImageTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the auto trigger for base image dependency updates. - """ + +class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the auto trigger for base image dependency updates.""" ALL = "All" RUNTIME = "Runtime" -class OS(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operating system type required for the run. - """ + +class OS(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type required for the run.""" WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of a run. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a run.""" CREATING = "Creating" UPDATING = "Updating" @@ -51,18 +49,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the run. - """ + +class RunStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the run.""" QUEUED = "Queued" STARTED = "Started" @@ -73,16 +71,17 @@ class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" TIMEOUT = "Timeout" -class RunType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of run. - """ + +class RunType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of run.""" QUICK_BUILD = "QuickBuild" QUICK_RUN = "QuickRun" AUTO_BUILD = "AutoBuild" AUTO_RUN = "AutoRun" -class SecretObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecretObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the secret object which determines how the value of the secret object has to be interpreted. """ @@ -90,14 +89,15 @@ class SecretObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): OPAQUE = "Opaque" VAULTSECRET = "Vaultsecret" -class SourceControlType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source control service. - """ + +class SourceControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source control service.""" GITHUB = "Github" VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" -class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceRegistryLoginMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to @@ -107,43 +107,45 @@ class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) NONE = "None" DEFAULT = "Default" -class SourceTriggerEvent(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceTriggerEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SourceTriggerEvent.""" COMMIT = "commit" PULLREQUEST = "pullrequest" -class StepType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the step. - """ + +class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the step.""" DOCKER = "Docker" FILE_TASK = "FileTask" ENCODED_TASK = "EncodedTask" -class TaskStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of task. - """ + +class TaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of task.""" DISABLED = "Disabled" ENABLED = "Enabled" -class TokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of Auth token. - """ + +class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of Auth token.""" PAT = "PAT" O_AUTH = "OAuth" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of trigger.""" DISABLED = "Disabled" ENABLED = "Enabled" -class Variant(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Variant of the CPU. - """ + +class Variant(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Variant of the CPU.""" V6 = "v6" V7 = "v7" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_models_py3.py index 0958de68e6c7..750d67213965 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AgentProperties(msrest.serialization.Model): +class AgentProperties(_serialization.Model): """The properties that determine the run agent configuration. :ivar cpu: The CPU configuration in terms of number of cores required for the run. @@ -22,31 +25,26 @@ class AgentProperties(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "int"}, } - def __init__( - self, - *, - cpu: Optional[int] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[int] = None, **kwargs): """ :keyword cpu: The CPU configuration in terms of number of cores required for the run. :paramtype cpu: int """ - super(AgentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu -class Argument(msrest.serialization.Model): +class Argument(_serialization.Model): """The properties of a run argument. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the argument. + :ivar name: The name of the argument. Required. :vartype name: str - :ivar value: Required. The value of the argument. + :ivar value: The value of the argument. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. @@ -54,47 +52,40 @@ class Argument(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the argument. + :keyword name: The name of the argument. Required. :paramtype name: str - :keyword value: Required. The value of the argument. + :keyword value: The value of the argument. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. :paramtype is_secret: bool """ - super(Argument, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class AuthInfo(msrest.serialization.Model): +class AuthInfo(_serialization.Model): """The authorization properties for accessing the source code repository. All required parameters must be populated in order to send to Azure. - :ivar token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TokenType - :ivar token: Required. The access token used to access the source control provider. + :ivar token: The access token used to access the source control provider. Required. :vartype token: str :ivar refresh_token: The refresh token used to refresh the access token. :vartype refresh_token: str @@ -105,22 +96,22 @@ class AuthInfo(msrest.serialization.Model): """ _validation = { - 'token_type': {'required': True}, - 'token': {'required': True}, + "token_type": {"required": True}, + "token": {"required": True}, } _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Union[str, "TokenType"], + token_type: Union[str, "_models.TokenType"], token: str, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -128,9 +119,9 @@ def __init__( **kwargs ): """ - :keyword token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TokenType - :keyword token: Required. The access token used to access the source control provider. + :keyword token: The access token used to access the source control provider. Required. :paramtype token: str :keyword refresh_token: The refresh token used to refresh the access token. :paramtype refresh_token: str @@ -139,7 +130,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -147,10 +138,10 @@ def __init__( self.expires_in = expires_in -class AuthInfoUpdateParameters(msrest.serialization.Model): +class AuthInfoUpdateParameters(_serialization.Model): """The authorization properties for accessing the source code repository. - :ivar token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TokenType :ivar token: The access token used to access the source control provider. :vartype token: str @@ -163,17 +154,17 @@ class AuthInfoUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Optional[Union[str, "TokenType"]] = None, + token_type: Optional[Union[str, "_models.TokenType"]] = None, token: Optional[str] = None, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -181,7 +172,7 @@ def __init__( **kwargs ): """ - :keyword token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TokenType :keyword token: The access token used to access the source control provider. :paramtype token: str @@ -192,7 +183,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfoUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -200,11 +191,10 @@ def __init__( self.expires_in = expires_in -class BaseImageDependency(msrest.serialization.Model): +class BaseImageDependency(_serialization.Model): """Properties that describe a base image dependency. - :ivar type: The type of the base image dependency. Possible values include: "BuildTime", - "RunTime". + :ivar type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependencyType :ivar registry: The registry login server. :vartype registry: str @@ -217,17 +207,17 @@ class BaseImageDependency(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "BaseImageDependencyType"]] = None, + type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, registry: Optional[str] = None, repository: Optional[str] = None, tag: Optional[str] = None, @@ -235,7 +225,7 @@ def __init__( **kwargs ): """ - :keyword type: The type of the base image dependency. Possible values include: "BuildTime", + :keyword type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependencyType @@ -248,7 +238,7 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(BaseImageDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.registry = registry self.repository = repository @@ -256,106 +246,106 @@ def __init__( self.digest = digest -class BaseImageTrigger(msrest.serialization.Model): +class BaseImageTrigger(_serialization.Model): """The trigger based on base image dependency. All required parameters must be populated in order to send to Azure. - :ivar base_image_trigger_type: Required. The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. + Required. Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'base_image_trigger_type': {'required': True}, - 'name': {'required': True}, + "base_image_trigger_type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - base_image_trigger_type: Union[str, "BaseImageTriggerType"], + base_image_trigger_type: Union[str, "_models.BaseImageTriggerType"], name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword base_image_trigger_type: Required. The type of the auto trigger for base image - dependency updates. Possible values include: "All", "Runtime". + :keyword base_image_trigger_type: The type of the auto trigger for base image dependency + updates. Required. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.status = status self.name = name -class BaseImageTriggerUpdateParameters(msrest.serialization.Model): +class BaseImageTriggerUpdateParameters(_serialization.Model): """The properties for updating base image dependency trigger. All required parameters must be populated in order to send to Azure. :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime". + Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - base_image_trigger_type: Optional[Union[str, "BaseImageTriggerType"]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + base_image_trigger_type: Optional[Union[str, "_models.BaseImageTriggerType"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ :keyword base_image_trigger_type: The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + updates. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.status = status self.name = name -class Credentials(msrest.serialization.Model): +class Credentials(_serialization.Model): """The parameters that describes a set of credentials that will be used when a run is invoked. :ivar source_registry: Describes the credential parameters for accessing the source registry. @@ -370,15 +360,15 @@ class Credentials(msrest.serialization.Model): """ _attribute_map = { - 'source_registry': {'key': 'sourceRegistry', 'type': 'SourceRegistryCredentials'}, - 'custom_registries': {'key': 'customRegistries', 'type': '{CustomRegistryCredentials}'}, + "source_registry": {"key": "sourceRegistry", "type": "SourceRegistryCredentials"}, + "custom_registries": {"key": "customRegistries", "type": "{CustomRegistryCredentials}"}, } def __init__( self, *, - source_registry: Optional["SourceRegistryCredentials"] = None, - custom_registries: Optional[Dict[str, "CustomRegistryCredentials"]] = None, + source_registry: Optional["_models.SourceRegistryCredentials"] = None, + custom_registries: Optional[Dict[str, "_models.CustomRegistryCredentials"]] = None, **kwargs ): """ @@ -393,12 +383,12 @@ def __init__( :paramtype custom_registries: dict[str, ~azure.mgmt.containerregistry.v2019_04_01.models.CustomRegistryCredentials] """ - super(Credentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_registry = source_registry self.custom_registries = custom_registries -class CustomRegistryCredentials(msrest.serialization.Model): +class CustomRegistryCredentials(_serialization.Model): """Describes the credentials that will be used to access a custom registry during a run. :ivar user_name: The username for logging into the custom registry. @@ -417,16 +407,16 @@ class CustomRegistryCredentials(msrest.serialization.Model): """ _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'SecretObject'}, - 'password': {'key': 'password', 'type': 'SecretObject'}, - 'identity': {'key': 'identity', 'type': 'str'}, + "user_name": {"key": "userName", "type": "SecretObject"}, + "password": {"key": "password", "type": "SecretObject"}, + "identity": {"key": "identity", "type": "str"}, } def __init__( self, *, - user_name: Optional["SecretObject"] = None, - password: Optional["SecretObject"] = None, + user_name: Optional["_models.SecretObject"] = None, + password: Optional["_models.SecretObject"] = None, identity: Optional[str] = None, **kwargs ): @@ -445,21 +435,21 @@ def __init__( source of authentication used for accessing the registry. :paramtype identity: str """ - super(CustomRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.password = password self.identity = identity -class RunRequest(msrest.serialization.Model): +class RunRequest(_serialization.Model): """The request parameters for scheduling a run. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -467,40 +457,40 @@ class RunRequest(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } _subtype_map = { - 'type': {'DockerBuildRequest': 'DockerBuildRequest', 'EncodedTaskRunRequest': 'EncodedTaskRunRequest', 'FileTaskRunRequest': 'FileTaskRunRequest', 'TaskRunRequest': 'TaskRunRequest'} + "type": { + "DockerBuildRequest": "DockerBuildRequest", + "EncodedTaskRunRequest": "EncodedTaskRunRequest", + "FileTaskRunRequest": "FileTaskRunRequest", + "TaskRunRequest": "TaskRunRequest", + } } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, is_archive_enabled: bool = False, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool """ - super(RunRequest, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.is_archive_enabled = is_archive_enabled -class DockerBuildRequest(RunRequest): +class DockerBuildRequest(RunRequest): # pylint: disable=too-many-instance-attributes """The parameters for a docker quick build. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -512,7 +502,7 @@ class DockerBuildRequest(RunRequest): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source location. + :ivar docker_file_path: The Docker file path relative to the source location. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -520,7 +510,7 @@ class DockerBuildRequest(RunRequest): :vartype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties @@ -535,43 +525,43 @@ class DockerBuildRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'docker_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True}, + "docker_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, docker_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + arguments: Optional[List["_models.Argument"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ @@ -586,7 +576,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source location. + :keyword docker_file_path: The Docker file path relative to the source location. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -594,7 +584,7 @@ def __init__( :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -608,8 +598,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ - super(DockerBuildRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'DockerBuildRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "DockerBuildRequest" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -623,18 +613,18 @@ def __init__( self.credentials = credentials -class TaskStepProperties(msrest.serialization.Model): +class TaskStepProperties(_serialization.Model): """Base properties for any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStep, EncodedTaskStep, FileTaskStep. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStep, EncodedTaskStep, FileTaskStep 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 the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -647,28 +637,20 @@ class TaskStepProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } - _subtype_map = { - 'type': {'Docker': 'DockerBuildStep', 'EncodedTask': 'EncodedTaskStep', 'FileTask': 'FileTaskStep'} - } + _subtype_map = {"type": {"Docker": "DockerBuildStep", "EncodedTask": "EncodedTaskStep", "FileTask": "FileTaskStep"}} - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -676,8 +658,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepProperties, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.base_image_dependencies = None self.context_path = context_path self.context_access_token = context_access_token @@ -690,8 +672,8 @@ class DockerBuildStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -708,7 +690,7 @@ class DockerBuildStep(TaskStepProperties): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source context. + :ivar docker_file_path: The Docker file path relative to the source context. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -718,22 +700,22 @@ class DockerBuildStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'docker_file_path': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "docker_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, } def __init__( @@ -743,10 +725,10 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, **kwargs ): """ @@ -763,7 +745,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source context. + :keyword docker_file_path: The Docker file path relative to the source context. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -771,8 +753,8 @@ def __init__( step. :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] """ - super(DockerBuildStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -781,16 +763,16 @@ def __init__( self.arguments = arguments -class TaskStepUpdateParameters(msrest.serialization.Model): +class TaskStepUpdateParameters(_serialization.Model): """Base properties for updating any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -800,26 +782,24 @@ class TaskStepUpdateParameters(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } _subtype_map = { - 'type': {'Docker': 'DockerBuildStepUpdateParameters', 'EncodedTask': 'EncodedTaskStepUpdateParameters', 'FileTask': 'FileTaskStepUpdateParameters'} + "type": { + "Docker": "DockerBuildStepUpdateParameters", + "EncodedTask": "EncodedTaskStepUpdateParameters", + "FileTask": "FileTaskStepUpdateParameters", + } } - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -827,8 +807,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepUpdateParameters, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.context_path = context_path self.context_access_token = context_access_token @@ -838,8 +818,8 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -863,19 +843,19 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'target': {'key': 'target', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "target": {"key": "target", "type": "str"}, } def __init__( @@ -887,7 +867,7 @@ def __init__( is_push_enabled: Optional[bool] = None, no_cache: Optional[bool] = None, docker_file_path: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, target: Optional[str] = None, **kwargs ): @@ -913,8 +893,8 @@ def __init__( :keyword target: The name of the target build stage for the docker build. :paramtype target: str """ - super(DockerBuildStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -928,13 +908,13 @@ class EncodedTaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -942,7 +922,7 @@ class EncodedTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties @@ -957,45 +937,45 @@ class EncodedTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'encoded_task_content': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True}, + "encoded_task_content": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, encoded_task_content: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str @@ -1003,7 +983,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -1017,8 +997,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ - super(EncodedTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'EncodedTaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "EncodedTaskRunRequest" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1036,8 +1016,8 @@ class EncodedTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1047,8 +1027,8 @@ class EncodedTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -1057,19 +1037,19 @@ class EncodedTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'encoded_task_content': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "encoded_task_content": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1079,7 +1059,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1088,16 +1068,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ - super(EncodedTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1108,8 +1088,8 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1125,16 +1105,16 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1144,7 +1124,7 @@ def __init__( context_access_token: Optional[str] = None, encoded_task_content: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1160,8 +1140,8 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ - super(EncodedTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1172,12 +1152,12 @@ class FileTaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar task_file_path: Required. The template/definition file path relative to the source. + :ivar task_file_path: The template/definition file path relative to the source. Required. :vartype task_file_path: str :ivar values_file_path: The values/parameters file path relative to the source. :vartype values_file_path: str @@ -1185,7 +1165,7 @@ class FileTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties @@ -1200,44 +1180,44 @@ class FileTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'task_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True}, + "task_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, task_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword task_file_path: Required. The template/definition file path relative to the source. + :keyword task_file_path: The template/definition file path relative to the source. Required. :paramtype task_file_path: str :keyword values_file_path: The values/parameters file path relative to the source. :paramtype values_file_path: str @@ -1245,7 +1225,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. :paramtype agent_configuration: @@ -1259,8 +1239,8 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ - super(FileTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'FileTaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "FileTaskRunRequest" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1278,8 +1258,8 @@ class FileTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1289,8 +1269,8 @@ class FileTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar task_file_path: Required. The task template/definition file path relative to the source - context. + :ivar task_file_path: The task template/definition file path relative to the source context. + Required. :vartype task_file_path: str :ivar values_file_path: The task values/parameters file path relative to the source context. :vartype values_file_path: str @@ -1299,19 +1279,19 @@ class FileTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'task_file_path': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "task_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1321,7 +1301,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1330,16 +1310,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword task_file_path: Required. The task template/definition file path relative to the - source context. + :keyword task_file_path: The task template/definition file path relative to the source context. + Required. :paramtype task_file_path: str :keyword values_file_path: The task values/parameters file path relative to the source context. :paramtype values_file_path: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ - super(FileTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1350,8 +1330,8 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1367,16 +1347,16 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1386,7 +1366,7 @@ def __init__( context_access_token: Optional[str] = None, task_file_path: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1402,22 +1382,22 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ - super(FileTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity @@ -1429,10 +1409,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1440,8 +1420,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1449,8 +1429,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity @@ -1460,14 +1440,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2019_04_01.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImageDescriptor(msrest.serialization.Model): +class ImageDescriptor(_serialization.Model): """Properties for a registry image. :ivar registry: The registry login server. @@ -1481,10 +1461,10 @@ class ImageDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( @@ -1506,14 +1486,14 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(ImageDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry = registry self.repository = repository self.tag = tag self.digest = digest -class ImageUpdateTrigger(msrest.serialization.Model): +class ImageUpdateTrigger(_serialization.Model): """The image update trigger that caused a build. :ivar id: The unique ID of the trigger. @@ -1525,17 +1505,17 @@ class ImageUpdateTrigger(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'images': {'key': 'images', 'type': '[ImageDescriptor]'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "images": {"key": "images", "type": "[ImageDescriptor]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, - images: Optional[List["ImageDescriptor"]] = None, + images: Optional[List["_models.ImageDescriptor"]] = None, **kwargs ): """ @@ -1546,101 +1526,101 @@ def __init__( :keyword images: The list of image updates that caused the build. :paramtype images: list[~azure.mgmt.containerregistry.v2019_04_01.models.ImageDescriptor] """ - super(ImageUpdateTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.images = images -class PlatformProperties(msrest.serialization.Model): +class PlatformProperties(_serialization.Model): """The platform properties against which the run has to happen. All required parameters must be populated in order to send to Azure. - :ivar os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :ivar os: The operating system type required for the run. Required. Known values are: "Windows" + and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2019_04_01.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :vartype architecture: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant """ _validation = { - 'os': {'required': True}, + "os": {"required": True}, } _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Union[str, "OS"], - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Union[str, "_models.OS"], + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Required. Known values are: + "Windows" and "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2019_04_01.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant """ - super(PlatformProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class PlatformUpdateParameters(msrest.serialization.Model): +class PlatformUpdateParameters(_serialization.Model): """The properties for updating the platform configuration. - :ivar os: The operating system type required for the run. Possible values include: "Windows", + :ivar os: The operating system type required for the run. Known values are: "Windows" and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2019_04_01.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :vartype architecture: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant """ _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Optional[Union[str, "OS"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Optional[Union[str, "_models.OS"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Known values are: "Windows" and + "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2019_04_01.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "arm". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", and "arm". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant """ - super(PlatformUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -1654,30 +1634,26 @@ class ProxyResource(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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1690,43 +1666,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1734,7 +1704,7 @@ def __init__( self.tags = tags -class Run(ProxyResource): +class Run(ProxyResource): # pylint: disable=too-many-instance-attributes """Run resource properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1747,13 +1717,13 @@ class Run(ProxyResource): :vartype type: str :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunStatus :ivar last_updated_time: The last updated time for the run. :vartype last_updated_time: ~datetime.datetime - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunType :ivar create_time: The time the run was scheduled. :vartype create_time: ~datetime.datetime @@ -1785,8 +1755,8 @@ class Run(ProxyResource): :ivar run_error_message: The error message received from backend systems after the run is scheduled. :vartype run_error_message: str - :ivar provisioning_state: The provisioning state of a run. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_04_01.models.ProvisioningState :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -1796,70 +1766,70 @@ class Run(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'run_error_message': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "run_error_message": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'run_id': {'key': 'properties.runId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'run_type': {'key': 'properties.runType', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'properties.finishTime', 'type': 'iso-8601'}, - 'output_images': {'key': 'properties.outputImages', 'type': '[ImageDescriptor]'}, - 'task': {'key': 'properties.task', 'type': 'str'}, - 'image_update_trigger': {'key': 'properties.imageUpdateTrigger', 'type': 'ImageUpdateTrigger'}, - 'source_trigger': {'key': 'properties.sourceTrigger', 'type': 'SourceTriggerDescriptor'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'source_registry_auth': {'key': 'properties.sourceRegistryAuth', 'type': 'str'}, - 'custom_registries': {'key': 'properties.customRegistries', 'type': '[str]'}, - 'run_error_message': {'key': 'properties.runErrorMessage', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_archive_enabled': {'key': 'properties.isArchiveEnabled', 'type': 'bool'}, - 'timer_trigger': {'key': 'properties.timerTrigger', 'type': 'TimerTriggerDescriptor'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "run_id": {"key": "properties.runId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "run_type": {"key": "properties.runType", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "finish_time": {"key": "properties.finishTime", "type": "iso-8601"}, + "output_images": {"key": "properties.outputImages", "type": "[ImageDescriptor]"}, + "task": {"key": "properties.task", "type": "str"}, + "image_update_trigger": {"key": "properties.imageUpdateTrigger", "type": "ImageUpdateTrigger"}, + "source_trigger": {"key": "properties.sourceTrigger", "type": "SourceTriggerDescriptor"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "source_registry_auth": {"key": "properties.sourceRegistryAuth", "type": "str"}, + "custom_registries": {"key": "properties.customRegistries", "type": "[str]"}, + "run_error_message": {"key": "properties.runErrorMessage", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_archive_enabled": {"key": "properties.isArchiveEnabled", "type": "bool"}, + "timer_trigger": {"key": "properties.timerTrigger", "type": "TimerTriggerDescriptor"}, } def __init__( self, *, run_id: Optional[str] = None, - status: Optional[Union[str, "RunStatus"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, last_updated_time: Optional[datetime.datetime] = None, - run_type: Optional[Union[str, "RunType"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, create_time: Optional[datetime.datetime] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - output_images: Optional[List["ImageDescriptor"]] = None, + output_images: Optional[List["_models.ImageDescriptor"]] = None, task: Optional[str] = None, - image_update_trigger: Optional["ImageUpdateTrigger"] = None, - source_trigger: Optional["SourceTriggerDescriptor"] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, + image_update_trigger: Optional["_models.ImageUpdateTrigger"] = None, + source_trigger: Optional["_models.SourceTriggerDescriptor"] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, source_registry_auth: Optional[str] = None, custom_registries: Optional[List[str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - is_archive_enabled: Optional[bool] = False, - timer_trigger: Optional["TimerTriggerDescriptor"] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + is_archive_enabled: bool = False, + timer_trigger: Optional["_models.TimerTriggerDescriptor"] = None, **kwargs ): """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunStatus :keyword last_updated_time: The last updated time for the run. :paramtype last_updated_time: ~datetime.datetime - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunType :keyword create_time: The time the run was scheduled. :paramtype create_time: ~datetime.datetime @@ -1890,8 +1860,8 @@ def __init__( :paramtype source_registry_auth: str :keyword custom_registries: The list of custom registries that were logged in during this run. :paramtype custom_registries: list[str] - :keyword provisioning_state: The provisioning state of a run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :keyword provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :paramtype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_04_01.models.ProvisioningState :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -1900,7 +1870,7 @@ def __init__( :paramtype timer_trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TimerTriggerDescriptor """ - super(Run, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.status = status self.last_updated_time = last_updated_time @@ -1922,16 +1892,16 @@ def __init__( self.timer_trigger = timer_trigger -class RunFilter(msrest.serialization.Model): +class RunFilter(_serialization.Model): """Properties that are enabled for Odata querying on runs. :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunType - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunStatus :ivar create_time: The create time for a run. :vartype create_time: ~datetime.datetime @@ -1948,22 +1918,22 @@ class RunFilter(msrest.serialization.Model): """ _attribute_map = { - 'run_id': {'key': 'runId', 'type': 'str'}, - 'run_type': {'key': 'runType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'create_time': {'key': 'createTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'output_image_manifests': {'key': 'outputImageManifests', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, + "run_id": {"key": "runId", "type": "str"}, + "run_type": {"key": "runType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "create_time": {"key": "createTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "output_image_manifests": {"key": "outputImageManifests", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_name": {"key": "taskName", "type": "str"}, } def __init__( self, *, run_id: Optional[str] = None, - run_type: Optional[Union[str, "RunType"]] = None, - status: Optional[Union[str, "RunStatus"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, create_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, output_image_manifests: Optional[str] = None, @@ -1974,11 +1944,11 @@ def __init__( """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunType - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.RunStatus :keyword create_time: The create time for a run. :paramtype create_time: ~datetime.datetime @@ -1993,7 +1963,7 @@ def __init__( :keyword task_name: The name of the task that the run corresponds to. :paramtype task_name: str """ - super(RunFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.run_type = run_type self.status = status @@ -2004,7 +1974,7 @@ def __init__( self.task_name = task_name -class RunGetLogResult(msrest.serialization.Model): +class RunGetLogResult(_serialization.Model): """The result of get log link operation. :ivar log_link: The link to logs for a run on a azure container registry. @@ -2012,24 +1982,19 @@ class RunGetLogResult(msrest.serialization.Model): """ _attribute_map = { - 'log_link': {'key': 'logLink', 'type': 'str'}, + "log_link": {"key": "logLink", "type": "str"}, } - def __init__( - self, - *, - log_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, log_link: Optional[str] = None, **kwargs): """ :keyword log_link: The link to logs for a run on a azure container registry. :paramtype log_link: str """ - super(RunGetLogResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_link = log_link -class RunListResult(msrest.serialization.Model): +class RunListResult(_serialization.Model): """Collection of runs. :ivar value: The collection value. @@ -2039,29 +2004,23 @@ class RunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Run]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Run]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Run"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Run"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_04_01.models.Run] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(RunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RunUpdateParameters(msrest.serialization.Model): +class RunUpdateParameters(_serialization.Model): """The set of run properties that can be updated. :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -2069,24 +2028,19 @@ class RunUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(RunUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_archive_enabled = is_archive_enabled -class SecretObject(msrest.serialization.Model): +class SecretObject(_serialization.Model): """Describes the properties of a secret object value. :ivar value: The value of the secret. The format of this value will be determined @@ -2095,21 +2049,17 @@ class SecretObject(msrest.serialization.Model): :vartype value: str :ivar type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque", "Vaultsecret". + interpreted. Known values are: "Opaque" and "Vaultsecret". :vartype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObjectType """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( - self, - *, - value: Optional[str] = None, - type: Optional[Union[str, "SecretObjectType"]] = None, - **kwargs + self, *, value: Optional[str] = None, type: Optional[Union[str, "_models.SecretObjectType"]] = None, **kwargs ): """ :keyword value: The value of the secret. The format of this value will be determined @@ -2118,70 +2068,63 @@ def __init__( :paramtype value: str :keyword type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque", "Vaultsecret". + interpreted. Known values are: "Opaque" and "Vaultsecret". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObjectType """ - super(SecretObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.type = type -class SetValue(msrest.serialization.Model): +class SetValue(_serialization.Model): """The properties of a overridable value that can be passed to a task template. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the overridable value. + :ivar name: The name of the overridable value. Required. :vartype name: str - :ivar value: Required. The overridable value. + :ivar value: The overridable value. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the value represents a secret or not. :vartype is_secret: bool """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the overridable value. + :keyword name: The name of the overridable value. Required. :paramtype name: str - :keyword value: Required. The overridable value. + :keyword value: The overridable value. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the value represents a secret or not. :paramtype is_secret: bool """ - super(SetValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class SourceProperties(msrest.serialization.Model): +class SourceProperties(_serialization.Model): """The properties of the source code repository. All required parameters must be populated in order to send to Azure. - :ivar source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceControlType - :ivar repository_url: Required. The full URL to the source code repository. + :ivar repository_url: The full URL to the source code repository. Required. :vartype repository_url: str :ivar branch: The branch name of the source code. :vartype branch: str @@ -2193,32 +2136,32 @@ class SourceProperties(msrest.serialization.Model): """ _validation = { - 'source_control_type': {'required': True}, - 'repository_url': {'required': True}, + "source_control_type": {"required": True}, + "repository_url": {"required": True}, } _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfo'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfo"}, } def __init__( self, *, - source_control_type: Union[str, "SourceControlType"], + source_control_type: Union[str, "_models.SourceControlType"], repository_url: str, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfo"] = None, + source_control_auth_properties: Optional["_models.AuthInfo"] = None, **kwargs ): """ - :keyword source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceControlType - :keyword repository_url: Required. The full URL to the source code repository. + :keyword repository_url: The full URL to the source code repository. Required. :paramtype repository_url: str :keyword branch: The branch name of the source code. :paramtype branch: str @@ -2228,104 +2171,99 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfo """ - super(SourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceRegistryCredentials(msrest.serialization.Model): +class SourceRegistryCredentials(_serialization.Model): """Describes the credential parameters for accessing the source registry. :ivar login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :vartype login_mode: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceRegistryLoginMode """ _attribute_map = { - 'login_mode': {'key': 'loginMode', 'type': 'str'}, + "login_mode": {"key": "loginMode", "type": "str"}, } - def __init__( - self, - *, - login_mode: Optional[Union[str, "SourceRegistryLoginMode"]] = None, - **kwargs - ): + def __init__(self, *, login_mode: Optional[Union[str, "_models.SourceRegistryLoginMode"]] = None, **kwargs): """ :keyword login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :paramtype login_mode: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceRegistryLoginMode """ - super(SourceRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.login_mode = login_mode -class SourceTrigger(msrest.serialization.Model): +class SourceTrigger(_serialization.Model): """The properties of a source based trigger. All required parameters must be populated in order to send to Azure. - :ivar source_repository: Required. The properties that describes the source(code) for the task. + :ivar source_repository: The properties that describes the source(code) for the task. Required. :vartype source_repository: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceProperties - :ivar source_trigger_events: Required. The source event corresponding to the trigger. + :ivar source_trigger_events: The source event corresponding to the trigger. Required. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'source_repository': {'required': True}, - 'source_trigger_events': {'required': True}, - 'name': {'required': True}, + "source_repository": {"required": True}, + "source_trigger_events": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceProperties'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceProperties"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - source_repository: "SourceProperties", - source_trigger_events: List[Union[str, "SourceTriggerEvent"]], + source_repository: "_models.SourceProperties", + source_trigger_events: List[Union[str, "_models.SourceTriggerEvent"]], name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword source_repository: Required. The properties that describes the source(code) for the - task. + :keyword source_repository: The properties that describes the source(code) for the task. + Required. :paramtype source_repository: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceProperties - :keyword source_trigger_events: Required. The source event corresponding to the trigger. + :keyword source_trigger_events: The source event corresponding to the trigger. Required. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceTriggerDescriptor(msrest.serialization.Model): +class SourceTriggerDescriptor(_serialization.Model): """The source trigger that caused a run. :ivar id: The unique ID of the trigger. @@ -2345,19 +2283,19 @@ class SourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_type': {'key': 'eventType', 'type': 'str'}, - 'commit_id': {'key': 'commitId', 'type': 'str'}, - 'pull_request_id': {'key': 'pullRequestId', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch_name': {'key': 'branchName', 'type': 'str'}, - 'provider_type': {'key': 'providerType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "event_type": {"key": "eventType", "type": "str"}, + "commit_id": {"key": "commitId", "type": "str"}, + "pull_request_id": {"key": "pullRequestId", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch_name": {"key": "branchName", "type": "str"}, + "provider_type": {"key": "providerType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin event_type: Optional[str] = None, commit_id: Optional[str] = None, pull_request_id: Optional[str] = None, @@ -2382,7 +2320,7 @@ def __init__( :keyword provider_type: The source control provider type. :paramtype provider_type: str """ - super(SourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.event_type = event_type self.commit_id = commit_id @@ -2392,7 +2330,7 @@ def __init__( self.provider_type = provider_type -class SourceTriggerUpdateParameters(msrest.serialization.Model): +class SourceTriggerUpdateParameters(_serialization.Model): """The properties for updating a source based trigger. All required parameters must be populated in order to send to Azure. @@ -2403,30 +2341,30 @@ class SourceTriggerUpdateParameters(msrest.serialization.Model): :ivar source_trigger_events: The source event corresponding to the trigger. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceUpdateParameters'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceUpdateParameters"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - source_repository: Optional["SourceUpdateParameters"] = None, - source_trigger_events: Optional[List[Union[str, "SourceTriggerEvent"]]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + source_repository: Optional["_models.SourceUpdateParameters"] = None, + source_trigger_events: Optional[List[Union[str, "_models.SourceTriggerEvent"]]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ @@ -2436,23 +2374,23 @@ def __init__( :keyword source_trigger_events: The source event corresponding to the trigger. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceUpdateParameters(msrest.serialization.Model): +class SourceUpdateParameters(_serialization.Model): """The properties for updating the source code repository. - :ivar source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Known values are: "Github" and + "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceControlType :ivar repository_url: The full URL to the source code repository. @@ -2467,24 +2405,24 @@ class SourceUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfoUpdateParameters'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfoUpdateParameters"}, } def __init__( self, *, - source_control_type: Optional[Union[str, "SourceControlType"]] = None, + source_control_type: Optional[Union[str, "_models.SourceControlType"]] = None, repository_url: Optional[str] = None, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfoUpdateParameters"] = None, + source_control_auth_properties: Optional["_models.AuthInfoUpdateParameters"] = None, **kwargs ): """ - :keyword source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Known values are: "Github" + and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SourceControlType :keyword repository_url: The full URL to the source code repository. @@ -2497,14 +2435,14 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfoUpdateParameters """ - super(SourceUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceUploadDefinition(msrest.serialization.Model): +class SourceUploadDefinition(_serialization.Model): """The properties of a response to source upload request. :ivar upload_url: The URL where the client can upload the source. @@ -2515,17 +2453,11 @@ class SourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } - def __init__( - self, - *, - upload_url: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, upload_url: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword upload_url: The URL where the client can upload the source. :paramtype upload_url: str @@ -2533,81 +2465,81 @@ def __init__( queue build request. :paramtype relative_path: str """ - super(SourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.upload_url = upload_url self.relative_path = relative_path -class Task(Resource): - """The task that has the ARM resource and task properties. -The task will have all information to schedule a run against it. - - 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: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. - :vartype location: str - :ivar tags: A set of tags. The tags of the resource. - :vartype tags: dict[str, str] - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :ivar provisioning_state: The provisioning state of the task. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2019_04_01.models.ProvisioningState - :ivar creation_date: The creation date of task. - :vartype creation_date: ~datetime.datetime - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStatus - :ivar platform: The platform properties against which the run has to happen. - :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties - :ivar agent_configuration: The machine configuration of the run agent. - :vartype agent_configuration: ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :ivar step: The properties of a task step. - :vartype step: ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStepProperties - :ivar trigger: The properties that describe all triggers for the task. - :vartype trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerProperties - :ivar credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :vartype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials +class Task(Resource): # pylint: disable=too-many-instance-attributes + """The task that has the ARM resource and task properties. + The task will have all information to schedule a run against it. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties + :ivar provisioning_state: The provisioning state of the task. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_04_01.models.ProvisioningState + :ivar creation_date: The creation date of task. + :vartype creation_date: ~datetime.datetime + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStatus + :ivar platform: The platform properties against which the run has to happen. + :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties + :ivar agent_configuration: The machine configuration of the run agent. + :vartype agent_configuration: ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties + :ivar timeout: Run timeout in seconds. + :vartype timeout: int + :ivar step: The properties of a task step. + :vartype step: ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStepProperties + :ivar trigger: The properties that describe all triggers for the task. + :vartype trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerProperties + :ivar credentials: The properties that describes a set of credentials that will be used when + this run is invoked. + :vartype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "creation_date": {"readonly": True}, + "timeout": {"maximum": 28800, "minimum": 300}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerProperties'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepProperties"}, + "trigger": {"key": "properties.trigger", "type": "TriggerProperties"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, } def __init__( @@ -2615,25 +2547,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, - timeout: Optional[int] = 3600, - step: Optional["TaskStepProperties"] = None, - trigger: Optional["TriggerProperties"] = None, - credentials: Optional["Credentials"] = None, + identity: Optional["_models.IdentityProperties"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, + timeout: int = 3600, + step: Optional["_models.TaskStepProperties"] = None, + trigger: Optional["_models.TriggerProperties"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties @@ -2650,7 +2582,7 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ - super(Task, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.identity = identity self.provisioning_state = None self.creation_date = None @@ -2663,7 +2595,7 @@ def __init__( self.credentials = credentials -class TaskListResult(msrest.serialization.Model): +class TaskListResult(_serialization.Model): """The collection of tasks. :ivar value: The collection value. @@ -2673,24 +2605,18 @@ class TaskListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Task]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Task]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Task"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Task"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_04_01.models.Task] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(TaskListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2700,60 +2626,60 @@ class TaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :vartype is_archive_enabled: bool - :ivar task_name: Required. The name of task against which run has to be queued. + :ivar task_name: The name of task against which run has to be queued. Required. :vartype task_name: str :ivar values: The collection of overridable values that can be passed when running a task. :vartype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ _validation = { - 'type': {'required': True}, - 'task_name': {'required': True}, + "type": {"required": True}, + "task_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_name": {"key": "taskName", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( self, *, task_name: str, - is_archive_enabled: Optional[bool] = False, - values: Optional[List["SetValue"]] = None, + is_archive_enabled: bool = False, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. :paramtype is_archive_enabled: bool - :keyword task_name: Required. The name of task against which run has to be queued. + :keyword task_name: The name of task against which run has to be queued. Required. :paramtype task_name: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_04_01.models.SetValue] """ - super(TaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type = 'TaskRunRequest' # type: str + super().__init__(is_archive_enabled=is_archive_enabled, **kwargs) + self.type: str = "TaskRunRequest" self.task_name = task_name self.values = values -class TaskUpdateParameters(msrest.serialization.Model): +class TaskUpdateParameters(_serialization.Model): """The parameters for updating a task. :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStatus :ivar platform: The platform properties against which the run has to happen. :vartype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformUpdateParameters @@ -2771,37 +2697,37 @@ class TaskUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformUpdateParameters'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepUpdateParameters'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerUpdateParameters'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformUpdateParameters"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepUpdateParameters"}, + "trigger": {"key": "properties.trigger", "type": "TriggerUpdateParameters"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformUpdateParameters"] = None, - agent_configuration: Optional["AgentProperties"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformUpdateParameters"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, timeout: Optional[int] = None, - step: Optional["TaskStepUpdateParameters"] = None, - trigger: Optional["TriggerUpdateParameters"] = None, - credentials: Optional["Credentials"] = None, + step: Optional["_models.TaskStepUpdateParameters"] = None, + trigger: Optional["_models.TriggerUpdateParameters"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformUpdateParameters @@ -2818,7 +2744,7 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials """ - super(TaskUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.status = status @@ -2830,53 +2756,48 @@ def __init__( self.credentials = credentials -class TimerTrigger(msrest.serialization.Model): +class TimerTrigger(_serialization.Model): """The properties of a timer trigger. All required parameters must be populated in order to send to Azure. - :ivar schedule: Required. The CRON expression for the task schedule. + :ivar schedule: The CRON expression for the task schedule. Required. :vartype schedule: str - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'schedule': {'required': True}, - 'name': {'required': True}, + "schedule": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "schedule": {"key": "schedule", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - schedule: str, - name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, - **kwargs + self, *, schedule: str, name: str, status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword schedule: Required. The CRON expression for the task schedule. + :keyword schedule: The CRON expression for the task schedule. Required. :paramtype schedule: str - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(TimerTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.status = status self.name = name -class TimerTriggerDescriptor(msrest.serialization.Model): +class TimerTriggerDescriptor(_serialization.Model): """TimerTriggerDescriptor. :ivar timer_trigger_name: The timer trigger name that caused the run. @@ -2886,16 +2807,12 @@ class TimerTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timer_trigger_name': {'key': 'timerTriggerName', 'type': 'str'}, - 'schedule_occurrence': {'key': 'scheduleOccurrence', 'type': 'str'}, + "timer_trigger_name": {"key": "timerTriggerName", "type": "str"}, + "schedule_occurrence": {"key": "scheduleOccurrence", "type": "str"}, } def __init__( - self, - *, - timer_trigger_name: Optional[str] = None, - schedule_occurrence: Optional[str] = None, - **kwargs + self, *, timer_trigger_name: Optional[str] = None, schedule_occurrence: Optional[str] = None, **kwargs ): """ :keyword timer_trigger_name: The timer trigger name that caused the run. @@ -2903,32 +2820,32 @@ def __init__( :keyword schedule_occurrence: The occurrence that triggered the run. :paramtype schedule_occurrence: str """ - super(TimerTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_trigger_name = timer_trigger_name self.schedule_occurrence = schedule_occurrence -class TimerTriggerUpdateParameters(msrest.serialization.Model): +class TimerTriggerUpdateParameters(_serialization.Model): """The properties for updating a timer trigger. All required parameters must be populated in order to send to Azure. :ivar schedule: The CRON expression for the task schedule. :vartype schedule: str - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "schedule": {"key": "schedule", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2936,24 +2853,24 @@ def __init__( *, name: str, schedule: Optional[str] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ :keyword schedule: The CRON expression for the task schedule. :paramtype schedule: str - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(TimerTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.status = status self.name = name -class TriggerProperties(msrest.serialization.Model): +class TriggerProperties(_serialization.Model): """The properties of a trigger. :ivar timer_triggers: The collection of timer triggers. @@ -2965,17 +2882,17 @@ class TriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'timer_triggers': {'key': 'timerTriggers', 'type': '[TimerTrigger]'}, - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTrigger]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTrigger'}, + "timer_triggers": {"key": "timerTriggers", "type": "[TimerTrigger]"}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTrigger]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTrigger"}, } def __init__( self, *, - timer_triggers: Optional[List["TimerTrigger"]] = None, - source_triggers: Optional[List["SourceTrigger"]] = None, - base_image_trigger: Optional["BaseImageTrigger"] = None, + timer_triggers: Optional[List["_models.TimerTrigger"]] = None, + source_triggers: Optional[List["_models.SourceTrigger"]] = None, + base_image_trigger: Optional["_models.BaseImageTrigger"] = None, **kwargs ): """ @@ -2988,13 +2905,13 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTrigger """ - super(TriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_triggers = timer_triggers self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger -class TriggerUpdateParameters(msrest.serialization.Model): +class TriggerUpdateParameters(_serialization.Model): """The properties for updating triggers. :ivar timer_triggers: The collection of timer triggers. @@ -3009,17 +2926,17 @@ class TriggerUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'timer_triggers': {'key': 'timerTriggers', 'type': '[TimerTriggerUpdateParameters]'}, - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTriggerUpdateParameters]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTriggerUpdateParameters'}, + "timer_triggers": {"key": "timerTriggers", "type": "[TimerTriggerUpdateParameters]"}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTriggerUpdateParameters]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTriggerUpdateParameters"}, } def __init__( self, *, - timer_triggers: Optional[List["TimerTriggerUpdateParameters"]] = None, - source_triggers: Optional[List["SourceTriggerUpdateParameters"]] = None, - base_image_trigger: Optional["BaseImageTriggerUpdateParameters"] = None, + timer_triggers: Optional[List["_models.TimerTriggerUpdateParameters"]] = None, + source_triggers: Optional[List["_models.SourceTriggerUpdateParameters"]] = None, + base_image_trigger: Optional["_models.BaseImageTriggerUpdateParameters"] = None, **kwargs ): """ @@ -3033,13 +2950,13 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerUpdateParameters """ - super(TriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_triggers = timer_triggers self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -3049,23 +2966,17 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/__init__.py index bb338b8a913c..d0afbe0f997d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._runs_operations import RunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'RunsOperations', - 'TasksOperations', + "RegistriesOperations", + "RunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_registries_operations.py index 360c61c0ea8b..d548c9bad6e7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_registries_operations.py @@ -6,164 +6,174 @@ # 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, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_schedule_run_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_schedule_run_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_build_source_upload_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class RegistriesOperations(object): - """RegistriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -172,33 +182,39 @@ def _schedule_run_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace + @overload def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest + :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 @@ -209,17 +225,82 @@ def begin_schedule_run( Retry-After header is present. :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest 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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._schedule_run_initial( resource_group_name=resource_group_name, @@ -227,88 +308,97 @@ def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_runs_operations.py index 3a661c2c3b31..049533be72ba 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_runs_operations.py @@ -6,246 +6,237 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, registry_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_log_sas_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any +def build_cancel_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) - -class RunsOperations(object): - """RunsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -255,13 +246,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.RunListResult"]: + ) -> Iterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -271,43 +262,53 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Run or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -318,16 +319,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,112 +336,127 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -450,18 +464,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -469,21 +561,25 @@ def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters 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 @@ -494,17 +590,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -513,128 +609,138 @@ def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -644,25 +750,20 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace - def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_cancel(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> LROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -674,42 +775,48 @@ def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_tasks_operations.py index e03d97dd2d86..81c4c93afde5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_tasks_operations.py @@ -6,334 +6,330 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_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, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_details_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TasksOperations(object): - """TasksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_04_01.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Task or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -344,16 +340,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -363,112 +357,127 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-04-01") # type: str + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -476,18 +485,95 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task + :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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -495,20 +581,24 @@ def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task 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 @@ -519,17 +609,17 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -538,65 +628,72 @@ def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -606,25 +703,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -636,83 +730,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -720,18 +834,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -739,21 +931,25 @@ def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters 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 @@ -764,17 +960,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_04_01.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -783,92 +979,98 @@ def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get_details(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_configuration.py index e46cbbd9a315..9f3750cf642d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", "2019-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_container_registry_management_client.py index f52861f95d9e..a11322239209 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -34,9 +34,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2019_05_01.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2019_05_01.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -54,10 +54,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -66,12 +68,7 @@ def __init__( self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -80,7 +77,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 @@ -93,15 +90,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_metadata.json index 46d4a8993baf..a78e98046f78 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -102,4 +102,4 @@ "replications": "ReplicationsOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_configuration.py index a09d2e516e26..52c91a1eb8bd 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", "2019-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_container_registry_management_client.py index 31ecdfae4d89..fb15271f2ad1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -35,9 +35,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2019_05_01.aio.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2019_05_01.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,10 +55,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -67,12 +69,7 @@ def __init__( self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -81,7 +78,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/__init__.py index 3c302d08d747..7a8d7099ae3f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_operations.py index 97a979db33ec..62a56f27f2c0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_operations.py @@ -6,79 +6,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +115,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +132,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_registries_operations.py index 802de6f15527..eb191cf74fde 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_registries_operations.py @@ -6,82 +6,121 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,27 +130,103 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters 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 @@ -122,202 +237,279 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -325,36 +517,42 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry + :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 @@ -367,17 +565,86 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -385,63 +652,71 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -451,22 +726,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -478,80 +749,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -559,37 +850,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters 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 @@ -602,17 +973,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -620,76 +991,91 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -700,16 +1086,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -719,49 +1103,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -772,16 +1168,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -791,194 +1185,277 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_replications_operations.py index 83e449c66423..b186a0dfdd15 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_replications_operations.py @@ -6,147 +6,183 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +190,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +290,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication 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 @@ -199,17 +320,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -218,65 +339,72 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,25 +414,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -316,83 +441,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -400,18 +545,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -419,21 +646,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters 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 @@ -446,17 +677,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -465,82 +696,94 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +794,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +811,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_webhooks_operations.py index 9ad3d4100179..4bc2009598e8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/aio/operations/_webhooks_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +294,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters 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 @@ -200,17 +325,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +344,72 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +419,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -317,83 +446,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +550,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +651,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters 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 @@ -447,17 +682,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +701,94 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +799,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,191 +816,205 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -765,16 +1025,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -784,8 +1042,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/__init__.py index 9cfbb0bab4c1..99b38f5404dc 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/__init__.py @@ -54,80 +54,82 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - DefaultAction, - ImportMode, - PasswordName, - PolicyStatus, - ProvisioningState, - RegistryUsageUnit, - SkuName, - SkuTier, - TrustPolicyType, - WebhookAction, - WebhookStatus, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Actor', - 'CallbackConfig', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'IPRule', - 'ImportImageParameters', - 'ImportSource', - 'ImportSourceCredentials', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'Policies', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'Sku', - 'Source', - 'Status', - 'StorageAccountProperties', - 'Target', - 'TrustPolicy', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'DefaultAction', - 'ImportMode', - 'PasswordName', - 'PolicyStatus', - 'ProvisioningState', - 'RegistryUsageUnit', - 'SkuName', - 'SkuTier', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', + "Actor", + "CallbackConfig", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "IPRule", + "ImportImageParameters", + "ImportSource", + "ImportSourceCredentials", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "Policies", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "Sku", + "Source", + "Status", + "StorageAccountProperties", + "Target", + "TrustPolicy", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "DefaultAction", + "ImportMode", + "PasswordName", + "PolicyStatus", + "ProvisioningState", + "RegistryUsageUnit", + "SkuName", + "SkuTier", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_container_registry_management_client_enums.py index 58c12bf3e36f..f795ea138eb9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_container_registry_management_client_enums.py @@ -7,24 +7,23 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -32,23 +31,23 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the container registry at the time the operation was called. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the container registry at the time the operation was called.""" CREATING = "Creating" UPDATING = "Updating" @@ -57,38 +56,40 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -96,9 +97,9 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_models_py3.py index 0d0d795a664c..a9578e94320a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -23,63 +26,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -87,20 +79,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -118,17 +105,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -141,12 +128,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2019_05_01.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -168,25 +155,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -207,7 +194,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2019_05_01.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -217,7 +204,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -228,17 +215,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -246,12 +227,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -267,17 +248,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -296,7 +277,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -304,7 +285,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -320,11 +301,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -349,7 +330,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -357,12 +338,12 @@ def __init__( self.version = version -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -371,33 +352,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2019_05_01.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -406,18 +387,18 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2019_05_01.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories self.mode = mode -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -428,22 +409,22 @@ class ImportSource(msrest.serialization.Model): :vartype registry_uri: str :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -452,7 +433,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -463,104 +444,92 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. :vartype virtual_network_rules: @@ -570,26 +539,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -598,13 +567,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2019_05_01.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -619,10 +588,13 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -630,8 +602,8 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -645,14 +617,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2019_05_01.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -666,10 +638,10 @@ class OperationDisplayDefinition(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__( @@ -691,14 +663,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -710,16 +682,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -729,12 +697,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -752,12 +720,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -785,7 +753,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -794,7 +762,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -803,13 +771,13 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, **kwargs ): """ @@ -817,11 +785,11 @@ def __init__( :paramtype metric_specifications: list[~azure.mgmt.containerregistry.v2019_05_01.models.OperationMetricSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -833,17 +801,17 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -854,73 +822,63 @@ def __init__( :keyword retention_policy: The retention policy for a container registry. :paramtype retention_policy: ~azure.mgmt.containerregistry.v2019_05_01.models.RetentionPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -933,43 +891,37 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, 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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -977,7 +929,7 @@ def __init__( self.tags = tags -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -990,20 +942,20 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2019_05_01.models.Sku :ivar login_server: The URL that can be used to log into the container registry. :vartype login_server: str :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_05_01.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -1021,53 +973,53 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountProperties"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - admin_user_enabled: Optional[bool] = False, - storage_account: Optional["StorageAccountProperties"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, + admin_user_enabled: bool = False, + storage_account: Optional["_models.StorageAccountProperties"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2019_05_01.models.Sku :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. :paramtype admin_user_enabled: bool @@ -1080,7 +1032,7 @@ def __init__( :keyword policies: The policies for a container registry. :paramtype policies: ~azure.mgmt.containerregistry.v2019_05_01.models.Policies """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.login_server = None self.creation_date = None @@ -1092,7 +1044,7 @@ def __init__( self.policies = policies -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -1102,16 +1054,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1119,12 +1067,12 @@ def __init__( :keyword passwords: The list of passwords for a container registry. :paramtype passwords: list[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -1135,17 +1083,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -1153,53 +1095,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -1212,9 +1149,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -1234,48 +1171,44 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): """The parameters for updating a container registry. - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2019_05_01.models.Sku @@ -1288,25 +1221,25 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2019_05_01.models.Sku @@ -1317,7 +1250,7 @@ def __init__( :keyword policies: The policies for a container registry. :paramtype policies: ~azure.mgmt.containerregistry.v2019_05_01.models.Policies """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.sku = sku self.admin_user_enabled = admin_user_enabled @@ -1325,24 +1258,24 @@ def __init__( self.policies = policies -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -1351,27 +1284,27 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -1379,20 +1312,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -1409,13 +1337,13 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_05_01.models.ProvisioningState @@ -1424,44 +1352,38 @@ class Replication(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -1472,16 +1394,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -1490,37 +1408,32 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -1538,17 +1451,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -1569,7 +1482,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -1577,7 +1490,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1586,83 +1499,72 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2019_05_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -1673,17 +1575,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -1691,12 +1587,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -1710,71 +1606,62 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StorageAccountProperties(msrest.serialization.Model): +class StorageAccountProperties(_serialization.Model): """The properties of a storage account for a container registry. Only applicable to Classic SKU. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The resource ID of the storage account. + :ivar id: The resource ID of the storage account. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. The resource ID of the storage account. + :keyword id: The resource ID of the storage account. Required. :paramtype id: str """ - super(StorageAccountProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -1788,15 +1675,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1817,12 +1704,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -1834,7 +1721,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -1846,78 +1733,74 @@ def __init__( self.version = version -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2019_05_01.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2019_05_01.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2019_05_01.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -1935,13 +1818,13 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -1950,30 +1833,30 @@ class Webhook(Resource): :ivar actions: The list of actions that trigger the webhook to post notifications. :vartype actions: list[str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_05_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1981,19 +1864,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2002,29 +1885,29 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -2035,17 +1918,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -2055,23 +1938,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2080,7 +1963,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -2090,7 +1973,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -2101,17 +1984,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -2119,22 +1996,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -2145,12 +2022,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -2159,20 +2036,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2181,7 +2058,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/__init__.py index 3c302d08d747..7a8d7099ae3f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_operations.py index 1d245b54a0ce..01436e203827 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_operations.py @@ -6,108 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +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: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +137,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_registries_operations.py index 65d72f9d17c6..720dd30d49f4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_registries_operations.py @@ -6,503 +6,459 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,27 +468,103 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2019_05_01.models.ImportImageParameters 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 @@ -543,202 +575,279 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -746,36 +855,42 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry + :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 @@ -787,17 +902,84 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2019_05_01.models.Registry 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -805,63 +987,71 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -871,22 +1061,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -898,80 +1084,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -979,37 +1185,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUpdateParameters 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 @@ -1021,17 +1305,17 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1039,76 +1323,90 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1119,16 +1417,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1138,49 +1434,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1191,16 +1498,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1210,194 +1515,277 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_replications_operations.py index c511065e1bd8..360fbeeb1c08 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_replications_operations.py @@ -6,348 +6,356 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_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, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ReplicationsOperations(object): - """ReplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +363,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +463,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_05_01.models.Replication 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 @@ -400,17 +493,17 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +512,72 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +587,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -517,83 +614,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +718,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +819,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationUpdateParameters 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 @@ -647,17 +850,17 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -666,82 +869,94 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -752,16 +967,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -771,8 +984,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_webhooks_operations.py index 830f49552be3..b00c6da98690 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01/operations/_webhooks_operations.py @@ -6,462 +6,462 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_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, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WebhooksOperations(object): - """WebhooksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -469,18 +469,96 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -488,21 +566,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookCreateParameters 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 @@ -513,17 +595,17 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -532,65 +614,72 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -600,25 +689,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -630,83 +716,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -714,18 +820,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -733,21 +917,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01.models.WebhookUpdateParameters 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 @@ -758,17 +946,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -777,81 +965,93 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -862,16 +1062,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -881,191 +1079,202 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1076,16 +1285,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1095,8 +1302,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_configuration.py index c233caf90e37..92cd41cf4de3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + api_version: Literal["2019-05-01-preview"] = kwargs.pop("api_version", "2019-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_container_registry_management_client.py index 45f0f7b4e107..6a8cb0eb59a0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, ScopeMapsOperations, TokensOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar scope_maps: ScopeMapsOperations operations @@ -33,9 +33,9 @@ class ContainerRegistryManagementClient: :ivar registries: RegistriesOperations operations :vartype registries: azure.mgmt.containerregistry.v2019_05_01_preview.operations.RegistriesOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -53,10 +53,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -64,12 +66,7 @@ def __init__( self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.registries = RegistriesOperations(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 @@ -78,7 +75,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 @@ -91,15 +88,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_metadata.json index e9978fc18d0b..8120b650c130 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -101,4 +101,4 @@ "tokens": "TokensOperations", "registries": "RegistriesOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_configuration.py index b0d574a2d574..9981797714e9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + api_version: Literal["2019-05-01-preview"] = kwargs.pop("api_version", "2019-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_container_registry_management_client.py index aeef5f4dca61..4e7449548557 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import RegistriesOperations, ScopeMapsOperations, TokensOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar scope_maps: ScopeMapsOperations operations @@ -34,9 +34,9 @@ class ContainerRegistryManagementClient: :ivar registries: RegistriesOperations operations :vartype registries: azure.mgmt.containerregistry.v2019_05_01_preview.aio.operations.RegistriesOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -54,10 +54,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -65,12 +67,7 @@ def __init__( self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.registries = RegistriesOperations(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 @@ -79,7 +76,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/__init__.py index e349e8b3a617..ab10edd263a6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._tokens_operations import TokensOperations from ._registries_operations import RegistriesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScopeMapsOperations', - 'TokensOperations', - 'RegistriesOperations', + "ScopeMapsOperations", + "TokensOperations", + "RegistriesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_registries_operations.py index 967706b79f2b..2cc177824c11 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_registries_operations.py @@ -6,80 +6,108 @@ # 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, Union +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_generate_credentials_request_initial -T = TypeVar('T') +from ...operations._registries_operations import build_generate_credentials_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -88,34 +116,114 @@ async def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters 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 @@ -128,17 +236,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -146,29 +256,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_scope_maps_operations.py index b71130a1f8f0..fb81e0be5f4d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_scope_maps_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01-preview") # type: str + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +295,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap 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 @@ -200,17 +326,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +347,74 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +424,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -317,83 +451,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +559,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +660,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters 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 @@ -447,17 +691,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +712,96 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +812,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +829,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_tokens_operations.py index b9c2de0cc49c..7e14912aa2bc 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/aio/operations/_tokens_operations.py @@ -6,147 +6,185 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +192,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +290,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token + 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 @@ -198,17 +320,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -217,65 +341,74 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -285,25 +418,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -315,83 +445,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -399,18 +553,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -418,21 +652,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters 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 @@ -444,17 +682,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -463,81 +703,96 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -548,16 +803,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -567,8 +820,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/__init__.py index 9f28cef5c689..ed7bdf50c9eb 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/__init__.py @@ -21,35 +21,37 @@ from ._models_py3 import TokenPassword from ._models_py3 import TokenUpdateParameters - -from ._container_registry_management_client_enums import ( - CreatedByType, - LastModifiedByType, - ProvisioningState, - TokenCertificateName, - TokenPasswordName, - TokenStatus, -) +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActiveDirectoryObject', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'ProxyResource', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'SystemData', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'CreatedByType', - 'LastModifiedByType', - 'ProvisioningState', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', + "ActiveDirectoryObject", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "ProxyResource", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "SystemData", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "CreatedByType", + "LastModifiedByType", + "ProvisioningState", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_container_registry_management_client_enums.py index c885f77e3ec1..6237fac9199c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_container_registry_management_client_enums.py @@ -7,31 +7,29 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -40,21 +38,23 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_models_py3.py index 88be7d322550..dd27d1926b8b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -26,17 +29,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -45,12 +42,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -59,15 +56,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -75,7 +72,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -85,17 +82,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -106,16 +103,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -124,12 +117,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -145,26 +138,22 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -190,8 +179,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -201,34 +190,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -237,7 +220,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -245,7 +228,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -256,17 +239,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -274,12 +251,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -291,17 +268,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -310,26 +281,26 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -337,44 +308,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -398,8 +369,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -408,38 +379,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -449,11 +420,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -461,10 +432,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -477,23 +448,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -504,14 +475,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar active_directory_object: The Active Directory Object that will be used for authenticating @@ -527,17 +498,17 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'active_directory_object': {'key': 'activeDirectoryObject', 'type': 'ActiveDirectoryObject'}, - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "active_directory_object": {"key": "activeDirectoryObject", "type": "ActiveDirectoryObject"}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - active_directory_object: Optional["ActiveDirectoryObject"] = None, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + active_directory_object: Optional["_models.ActiveDirectoryObject"] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -552,13 +523,13 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.active_directory_object = active_directory_object self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -569,17 +540,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -587,12 +552,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -601,7 +566,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPasswordName @@ -610,14 +575,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -625,7 +590,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -633,26 +598,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -660,31 +625,31 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/__init__.py index e349e8b3a617..ab10edd263a6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/__init__.py @@ -10,8 +10,14 @@ from ._tokens_operations import TokensOperations from ._registries_operations import RegistriesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScopeMapsOperations', - 'TokensOperations', - 'RegistriesOperations', + "ScopeMapsOperations", + "TokensOperations", + "RegistriesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_registries_operations.py index 184fda06cabc..5bcae406a0ee 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_registries_operations.py @@ -6,128 +6,149 @@ # 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, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -136,34 +157,114 @@ def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsParameters 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 @@ -176,17 +277,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -194,29 +297,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_scope_maps_operations.py index a1dd0d4d8817..7deb1d71099a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_scope_maps_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,21 +474,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap 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 @@ -400,17 +504,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +525,74 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +602,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -517,83 +629,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +737,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +836,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapUpdateParameters 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 @@ -646,17 +866,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -665,81 +887,96 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -750,16 +987,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -769,8 +1004,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_tokens_operations.py index c026935cc32d..153233c0edf3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_05_01_preview/operations/_tokens_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_05_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,97 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +473,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token + 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 @@ -399,17 +503,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -418,65 +524,74 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -486,25 +601,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -516,83 +628,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -600,18 +736,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -619,21 +835,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenUpdateParameters 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 @@ -645,17 +865,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -664,81 +886,96 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_05_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-05-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -749,16 +986,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -768,8 +1003,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_configuration.py index 6df02e38c247..bb5d11217b8d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop("api_version", "2019-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py index 3dd18b8d1306..dedd9d58c29e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import AgentPoolsOperations, RegistriesOperations, RunsOperations, TaskRunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar agent_pools: AgentPoolsOperations operations @@ -38,9 +38,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2019_06_01_preview.operations.TaskRunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2019_06_01_preview.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -58,10 +58,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -71,12 +73,7 @@ def __init__( self.task_runs = TaskRunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -85,7 +82,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 @@ -98,15 +95,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_metadata.json index 6c1382ad7e1d..6507657abada 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -103,4 +103,4 @@ "task_runs": "TaskRunsOperations", "tasks": "TasksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_configuration.py index ca5c1e6c808e..2946ce8f6455 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop("api_version", "2019-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_container_registry_management_client.py index ec3358f321da..ada566ef0f97 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_container_registry_management_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration from .operations import AgentPoolsOperations, RegistriesOperations, RunsOperations, TaskRunsOperations, TasksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar agent_pools: AgentPoolsOperations operations @@ -38,9 +38,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2019_06_01_preview.aio.operations.TaskRunsOperations :ivar tasks: TasksOperations operations :vartype tasks: azure.mgmt.containerregistry.v2019_06_01_preview.aio.operations.TasksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -58,10 +58,12 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -71,12 +73,7 @@ def __init__( self.task_runs = TaskRunsOperations(self._client, self._config, self._serialize, self._deserialize) self.tasks = TasksOperations(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 @@ -85,7 +82,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/__init__.py index 50962a67c7b6..4e49224958c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._task_runs_operations import TaskRunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AgentPoolsOperations', - 'RegistriesOperations', - 'RunsOperations', - 'TaskRunsOperations', - 'TasksOperations', + "AgentPoolsOperations", + "RegistriesOperations", + "RunsOperations", + "TaskRunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_agent_pools_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_agent_pools_operations.py index a0bbc11854cd..6270a81c4d0a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_agent_pools_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_agent_pools_operations.py @@ -6,94 +6,118 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._agent_pools_operations import build_create_request_initial, build_delete_request_initial, build_get_queue_status_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._agent_pools_operations import ( + build_create_request, + build_delete_request, + build_get_queue_status_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AgentPoolsOperations: - """AgentPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AgentPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`agent_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.AgentPool": + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.AgentPool: """Gets the detailed information for a given agent pool. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AgentPool, or the result of cls(response) + :return: AgentPool or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,72 +125,171 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, agent_pool_name: str, - agent_pool: "_models.AgentPool", + agent_pool: Union[_models.AgentPool, IO], **kwargs: Any - ) -> "_models.AgentPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] + ) -> _models.AgentPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(agent_pool, 'AgentPool') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool, (IO, bytes)): + _content = agent_pool + else: + _json = self._serialize.body(agent_pool, "AgentPool") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + agent_pool: _models.AgentPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentPool]: + """Creates an agent pool for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param agent_pool: The parameters of an agent pool that needs to scheduled. Required. + :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool + :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 AgentPool or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + agent_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentPool]: + """Creates an agent pool for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param agent_pool: The parameters of an agent pool that needs to scheduled. Required. + :type agent_pool: 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 AgentPool or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -174,20 +297,24 @@ async def begin_create( resource_group_name: str, registry_name: str, agent_pool_name: str, - agent_pool: "_models.AgentPool", + agent_pool: Union[_models.AgentPool, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AgentPool"]: + ) -> AsyncLROPoller[_models.AgentPool]: """Creates an agent pool for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str - :param agent_pool: The parameters of an agent pool that needs to scheduled. - :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool + :param agent_pool: The parameters of an agent pool that needs to scheduled. Is either a model + type or a IO type. Required. + :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool 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 @@ -200,17 +327,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,93 +348,100 @@ async def begin_create( agent_pool=agent_pool, 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 = pipeline_response.http_response - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified agent pool resource. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_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. @@ -317,102 +453,209 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, agent_pool_name: str, - update_parameters: "_models.AgentPoolUpdateParameters", + update_parameters: Union[_models.AgentPoolUpdateParameters, IO], **kwargs: Any - ) -> "_models.AgentPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] + ) -> _models.AgentPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(update_parameters, 'AgentPoolUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "AgentPoolUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + update_parameters: _models.AgentPoolUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentPool]: + """Updates an agent pool with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param update_parameters: The parameters for updating an agent pool. Required. + :type update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters + :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 AgentPool or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentPool]: + """Updates an agent pool with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param update_parameters: The parameters for updating an agent pool. Required. + :type update_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 AgentPool or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +663,25 @@ async def begin_update( resource_group_name: str, registry_name: str, agent_pool_name: str, - update_parameters: "_models.AgentPoolUpdateParameters", + update_parameters: Union[_models.AgentPoolUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AgentPool"]: + ) -> AsyncLROPoller[_models.AgentPool]: """Updates an agent pool with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str - :param update_parameters: The parameters for updating an agent pool. + :param update_parameters: The parameters for updating an agent pool. Is either a model type or + a IO type. Required. :type update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters 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 @@ -447,17 +694,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +715,96 @@ async def begin_update( update_parameters=update_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 = pipeline_response.http_response - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AgentPoolListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.AgentPool"]: """Lists all the agent pools for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AgentPoolListResult or the result of cls(response) + :return: An iterator like instance of either AgentPool or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPoolListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +815,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AgentPoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -571,59 +833,63 @@ 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.ContainerRegistry/registries/{registryName}/agentPools"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools" + } @distributed_trace_async async def get_queue_status( - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.AgentPoolQueueStatus": + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.AgentPoolQueueStatus: """Gets the count of queued runs for a given agent pool. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AgentPoolQueueStatus, or the result of cls(response) + :return: AgentPoolQueueStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolQueueStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPoolQueueStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPoolQueueStatus] = kwargs.pop("cls", None) - request = build_get_queue_status_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_queue_status.metadata['url'], + template_url=self.get_queue_status.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,12 +897,13 @@ async def get_queue_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AgentPoolQueueStatus', pipeline_response) + deserialized = self._deserialize("AgentPoolQueueStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_queue_status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus"} # type: ignore - + get_queue_status.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_registries_operations.py index 3d698eecc3fd..2a81693937c6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_registries_operations.py @@ -6,115 +6,146 @@ # 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, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request_initial -T = TypeVar('T') +from ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace_async + @overload async def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest + :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 @@ -126,17 +157,86 @@ async def begin_schedule_run( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._schedule_run_initial( resource_group_name=resource_group_name, @@ -144,76 +244,86 @@ async def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace_async async def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -221,12 +331,13 @@ async def get_build_source_upload_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_runs_operations.py index 24b0dc836221..26c07ecbd7b4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_runs_operations.py @@ -6,46 +6,65 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._runs_operations import build_cancel_request_initial, build_get_log_sas_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._runs_operations import ( + build_cancel_request, + build_get_log_sas_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RunsOperations: - """RunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -55,13 +74,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.RunListResult"]: + ) -> AsyncIterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -71,43 +90,56 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) + :return: An iterator like instance of either Run or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +150,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -138,59 +168,61 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + async def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,72 +230,170 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Run]: + """Patch the run properties. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -271,21 +401,25 @@ async def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Run"]: + ) -> AsyncLROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters 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 @@ -297,17 +431,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -316,80 +452,89 @@ async def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace_async async def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -397,76 +542,79 @@ async def get_log_sas_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } async def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace_async - async def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + async def begin_cancel( + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -478,42 +626,50 @@ async def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_task_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_task_runs_operations.py index ce883d7c0f12..2efc0085d424 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_task_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_task_runs_operations.py @@ -6,94 +6,118 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._task_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_details_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._task_runs_operations import ( + build_create_request, + build_delete_request, + build_get_details_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TaskRunsOperations: - """TaskRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TaskRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`task_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any - ) -> "_models.TaskRun": + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any + ) -> _models.TaskRun: """Gets the detailed information for a given task run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TaskRun, or the result of cls(response) + :return: TaskRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,72 +125,171 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, task_run_name: str, - task_run: "_models.TaskRun", + task_run: Union[_models.TaskRun, IO], **kwargs: Any - ) -> "_models.TaskRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] + ) -> _models.TaskRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_run, 'TaskRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_run, (IO, bytes)): + _content = task_run + else: + _json = self._serialize.body(task_run, "TaskRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + task_run: _models.TaskRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TaskRun]: + """Creates a task run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param task_run: The parameters of a run that needs to scheduled. Required. + :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun + :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 TaskRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + task_run: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TaskRun]: + """Creates a task run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param task_run: The parameters of a run that needs to scheduled. Required. + :type task_run: 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 TaskRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -174,20 +297,24 @@ async def begin_create( resource_group_name: str, registry_name: str, task_run_name: str, - task_run: "_models.TaskRun", + task_run: Union[_models.TaskRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.TaskRun"]: + ) -> AsyncLROPoller[_models.TaskRun]: """Creates a task run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str - :param task_run: The parameters of a run that needs to scheduled. - :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun + :param task_run: The parameters of a run that needs to scheduled. Is either a model type or a + IO type. Required. + :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun 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 @@ -200,17 +327,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,93 +348,100 @@ async def begin_create( task_run=task_run, 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 = pipeline_response.http_response - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified task run resource. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_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. @@ -317,102 +453,209 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, task_run_name: str, - update_parameters: "_models.TaskRunUpdateParameters", + update_parameters: Union[_models.TaskRunUpdateParameters, IO], **kwargs: Any - ) -> "_models.TaskRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] + ) -> _models.TaskRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(update_parameters, 'TaskRunUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "TaskRunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + update_parameters: _models.TaskRunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TaskRun]: + """Updates a task run with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param update_parameters: The parameters for updating a task run. Required. + :type update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters + :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 TaskRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TaskRun]: + """Updates a task run with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param update_parameters: The parameters for updating a task run. Required. + :type update_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 TaskRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +663,25 @@ async def begin_update( resource_group_name: str, registry_name: str, task_run_name: str, - update_parameters: "_models.TaskRunUpdateParameters", + update_parameters: Union[_models.TaskRunUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.TaskRun"]: + ) -> AsyncLROPoller[_models.TaskRun]: """Updates a task run with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str - :param update_parameters: The parameters for updating a task run. + :param update_parameters: The parameters for updating a task run. Is either a model type or a + IO type. Required. :type update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters 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 @@ -447,17 +694,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,80 +715,89 @@ async def begin_update( update_parameters=update_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 = pipeline_response.http_response - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } @distributed_trace_async async def get_details( - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any - ) -> "_models.TaskRun": + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any + ) -> _models.TaskRun: """Gets the detailed information for a given task run that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TaskRun, or the result of cls(response) + :return: TaskRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -547,64 +805,75 @@ async def get_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TaskRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.TaskRun"]: """Lists all the task runs for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskRunListResult or the result of cls(response) + :return: An iterator like instance of either TaskRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -615,16 +884,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TaskRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -635,8 +902,8 @@ 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.ContainerRegistry/registries/{registryName}/taskRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_tasks_operations.py index 7be082da0e75..104a05685771 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/aio/operations/_tasks_operations.py @@ -6,95 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tasks_operations import build_create_request_initial, build_delete_request_initial, build_get_details_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tasks_operations import ( + build_create_request, + build_delete_request, + build_get_details_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TasksOperations: - """TasksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) + :return: An iterator like instance of either Task or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,59 +153,61 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + async def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,72 +215,169 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -258,20 +385,25 @@ async def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task 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 @@ -283,17 +415,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,93 +436,100 @@ async def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -400,102 +541,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +749,25 @@ async def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Task"]: + ) -> AsyncLROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters 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 @@ -529,17 +779,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -548,80 +800,89 @@ async def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace_async async def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any + ) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -629,12 +890,13 @@ async def get_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py index b73390bb476a..b60603ac2f1c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py @@ -71,113 +71,115 @@ from ._models_py3 import TriggerUpdateParameters from ._models_py3 import UserIdentityProperties - -from ._container_registry_management_client_enums import ( - Architecture, - BaseImageDependencyType, - BaseImageTriggerType, - CreatedByType, - LastModifiedByType, - OS, - ProvisioningState, - ResourceIdentityType, - RunStatus, - RunType, - SecretObjectType, - SourceControlType, - SourceRegistryLoginMode, - SourceTriggerEvent, - StepType, - TaskStatus, - TokenType, - TriggerStatus, - UpdateTriggerPayloadType, - Variant, -) +from ._container_registry_management_client_enums import Architecture +from ._container_registry_management_client_enums import BaseImageDependencyType +from ._container_registry_management_client_enums import BaseImageTriggerType +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import OS +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import RunStatus +from ._container_registry_management_client_enums import RunType +from ._container_registry_management_client_enums import SecretObjectType +from ._container_registry_management_client_enums import SourceControlType +from ._container_registry_management_client_enums import SourceRegistryLoginMode +from ._container_registry_management_client_enums import SourceTriggerEvent +from ._container_registry_management_client_enums import StepType +from ._container_registry_management_client_enums import TaskStatus +from ._container_registry_management_client_enums import TokenType +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import UpdateTriggerPayloadType +from ._container_registry_management_client_enums import Variant +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AgentPool', - 'AgentPoolListResult', - 'AgentPoolQueueStatus', - 'AgentPoolUpdateParameters', - 'AgentProperties', - 'Argument', - 'AuthInfo', - 'AuthInfoUpdateParameters', - 'BaseImageDependency', - 'BaseImageTrigger', - 'BaseImageTriggerUpdateParameters', - 'Credentials', - 'CustomRegistryCredentials', - 'DockerBuildRequest', - 'DockerBuildStep', - 'DockerBuildStepUpdateParameters', - 'EncodedTaskRunRequest', - 'EncodedTaskStep', - 'EncodedTaskStepUpdateParameters', - 'ErrorResponse', - 'ErrorResponseBody', - 'FileTaskRunRequest', - 'FileTaskStep', - 'FileTaskStepUpdateParameters', - 'IdentityProperties', - 'ImageDescriptor', - 'ImageUpdateTrigger', - 'InnerErrorDescription', - 'OverrideTaskStepProperties', - 'PlatformProperties', - 'PlatformUpdateParameters', - 'ProxyResource', - 'Resource', - 'Run', - 'RunFilter', - 'RunGetLogResult', - 'RunListResult', - 'RunRequest', - 'RunUpdateParameters', - 'SecretObject', - 'SetValue', - 'SourceProperties', - 'SourceRegistryCredentials', - 'SourceTrigger', - 'SourceTriggerDescriptor', - 'SourceTriggerUpdateParameters', - 'SourceUpdateParameters', - 'SourceUploadDefinition', - 'SystemData', - 'Task', - 'TaskListResult', - 'TaskRun', - 'TaskRunListResult', - 'TaskRunRequest', - 'TaskRunUpdateParameters', - 'TaskStepProperties', - 'TaskStepUpdateParameters', - 'TaskUpdateParameters', - 'TimerTrigger', - 'TimerTriggerDescriptor', - 'TimerTriggerUpdateParameters', - 'TriggerProperties', - 'TriggerUpdateParameters', - 'UserIdentityProperties', - 'Architecture', - 'BaseImageDependencyType', - 'BaseImageTriggerType', - 'CreatedByType', - 'LastModifiedByType', - 'OS', - 'ProvisioningState', - 'ResourceIdentityType', - 'RunStatus', - 'RunType', - 'SecretObjectType', - 'SourceControlType', - 'SourceRegistryLoginMode', - 'SourceTriggerEvent', - 'StepType', - 'TaskStatus', - 'TokenType', - 'TriggerStatus', - 'UpdateTriggerPayloadType', - 'Variant', + "AgentPool", + "AgentPoolListResult", + "AgentPoolQueueStatus", + "AgentPoolUpdateParameters", + "AgentProperties", + "Argument", + "AuthInfo", + "AuthInfoUpdateParameters", + "BaseImageDependency", + "BaseImageTrigger", + "BaseImageTriggerUpdateParameters", + "Credentials", + "CustomRegistryCredentials", + "DockerBuildRequest", + "DockerBuildStep", + "DockerBuildStepUpdateParameters", + "EncodedTaskRunRequest", + "EncodedTaskStep", + "EncodedTaskStepUpdateParameters", + "ErrorResponse", + "ErrorResponseBody", + "FileTaskRunRequest", + "FileTaskStep", + "FileTaskStepUpdateParameters", + "IdentityProperties", + "ImageDescriptor", + "ImageUpdateTrigger", + "InnerErrorDescription", + "OverrideTaskStepProperties", + "PlatformProperties", + "PlatformUpdateParameters", + "ProxyResource", + "Resource", + "Run", + "RunFilter", + "RunGetLogResult", + "RunListResult", + "RunRequest", + "RunUpdateParameters", + "SecretObject", + "SetValue", + "SourceProperties", + "SourceRegistryCredentials", + "SourceTrigger", + "SourceTriggerDescriptor", + "SourceTriggerUpdateParameters", + "SourceUpdateParameters", + "SourceUploadDefinition", + "SystemData", + "Task", + "TaskListResult", + "TaskRun", + "TaskRunListResult", + "TaskRunRequest", + "TaskRunUpdateParameters", + "TaskStepProperties", + "TaskStepUpdateParameters", + "TaskUpdateParameters", + "TimerTrigger", + "TimerTriggerDescriptor", + "TimerTriggerUpdateParameters", + "TriggerProperties", + "TriggerUpdateParameters", + "UserIdentityProperties", + "Architecture", + "BaseImageDependencyType", + "BaseImageTriggerType", + "CreatedByType", + "LastModifiedByType", + "OS", + "ProvisioningState", + "ResourceIdentityType", + "RunStatus", + "RunType", + "SecretObjectType", + "SourceControlType", + "SourceRegistryLoginMode", + "SourceTriggerEvent", + "StepType", + "TaskStatus", + "TokenType", + "TriggerStatus", + "UpdateTriggerPayloadType", + "Variant", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py index 2f4e87bb0939..265fe773a0a6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The OS architecture. - """ +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS architecture.""" AMD64 = "amd64" X86 = "x86" @@ -21,48 +19,48 @@ class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ARM = "arm" ARM64 = "arm64" -class BaseImageDependencyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the base image dependency. - """ + +class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the base image dependency.""" BUILD_TIME = "BuildTime" RUN_TIME = "RunTime" -class BaseImageTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the auto trigger for base image dependency updates. - """ + +class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the auto trigger for base image dependency updates.""" ALL = "All" RUNTIME = "Runtime" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class OS(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The OS of agent machine - """ + +class OS(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The OS of agent machine.""" WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of this agent pool - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of this agent pool.""" CREATING = "Creating" UPDATING = "Updating" @@ -71,18 +69,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the run. - """ + +class RunStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the run.""" QUEUED = "Queued" STARTED = "Started" @@ -93,16 +91,17 @@ class RunStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" TIMEOUT = "Timeout" -class RunType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of run. - """ + +class RunType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of run.""" QUICK_BUILD = "QuickBuild" QUICK_RUN = "QuickRun" AUTO_BUILD = "AutoBuild" AUTO_RUN = "AutoRun" -class SecretObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecretObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the secret object which determines how the value of the secret object has to be interpreted. """ @@ -110,14 +109,15 @@ class SecretObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): OPAQUE = "Opaque" VAULTSECRET = "Vaultsecret" -class SourceControlType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source control service. - """ + +class SourceControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source control service.""" GITHUB = "Github" VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" -class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceRegistryLoginMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to @@ -127,50 +127,52 @@ class SourceRegistryLoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) NONE = "None" DEFAULT = "Default" -class SourceTriggerEvent(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SourceTriggerEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SourceTriggerEvent.""" COMMIT = "commit" PULLREQUEST = "pullrequest" -class StepType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the step. - """ + +class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the step.""" DOCKER = "Docker" FILE_TASK = "FileTask" ENCODED_TASK = "EncodedTask" -class TaskStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of task. - """ + +class TaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of task.""" DISABLED = "Disabled" ENABLED = "Enabled" -class TokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of Auth token. - """ + +class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of Auth token.""" PAT = "PAT" O_AUTH = "OAuth" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of trigger.""" DISABLED = "Disabled" ENABLED = "Enabled" -class UpdateTriggerPayloadType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of Payload body for Base image update triggers. - """ + +class UpdateTriggerPayloadType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of Payload body for Base image update triggers.""" DEFAULT = "Default" TOKEN = "Token" -class Variant(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Variant of the CPU. - """ + +class Variant(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Variant of the CPU.""" V6 = "v6" V7 = "v7" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py index 98be0e88d745..68b854f29b39 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/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. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,47 +30,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -77,63 +73,63 @@ def __init__( self.system_data = None -class AgentPool(Resource): - """The agentpool that has the ARM resource and properties. -The agentpool will have all information to create an agent pool. - - 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: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. - :vartype location: str - :ivar tags: A set of tags. The tags of the resource. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData - :ivar count: The count of agent machine. - :vartype count: int - :ivar tier: The Tier of agent machine. - :vartype tier: str - :ivar os: The OS of agent machine. Possible values include: "Windows", "Linux". - :vartype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS - :ivar virtual_network_subnet_resource_id: The Virtual Network Subnet Resource Id of the agent - machine. - :vartype virtual_network_subnet_resource_id: str - :ivar provisioning_state: The provisioning state of this agent pool. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState +class AgentPool(Resource): # pylint: disable=too-many-instance-attributes + """The agentpool that has the ARM resource and properties. + The agentpool will have all information to create an agent pool. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData + :ivar count: The count of agent machine. + :vartype count: int + :ivar tier: The Tier of agent machine. + :vartype tier: str + :ivar os: The OS of agent machine. Known values are: "Windows" and "Linux". + :vartype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS + :ivar virtual_network_subnet_resource_id: The Virtual Network Subnet Resource Id of the agent + machine. + :vartype virtual_network_subnet_resource_id: str + :ivar provisioning_state: The provisioning state of this agent pool. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count': {'key': 'properties.count', 'type': 'int'}, - 'tier': {'key': 'properties.tier', 'type': 'str'}, - 'os': {'key': 'properties.os', 'type': 'str'}, - 'virtual_network_subnet_resource_id': {'key': 'properties.virtualNetworkSubnetResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "count": {"key": "properties.count", "type": "int"}, + "tier": {"key": "properties.tier", "type": "str"}, + "os": {"key": "properties.os", "type": "str"}, + "virtual_network_subnet_resource_id": {"key": "properties.virtualNetworkSubnetResourceId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -143,27 +139,27 @@ def __init__( tags: Optional[Dict[str, str]] = None, count: Optional[int] = None, tier: Optional[str] = None, - os: Optional[Union[str, "OS"]] = None, + os: Optional[Union[str, "_models.OS"]] = None, virtual_network_subnet_resource_id: Optional[str] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword count: The count of agent machine. :paramtype count: int :keyword tier: The Tier of agent machine. :paramtype tier: str - :keyword os: The OS of agent machine. Possible values include: "Windows", "Linux". + :keyword os: The OS of agent machine. Known values are: "Windows" and "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS :keyword virtual_network_subnet_resource_id: The Virtual Network Subnet Resource Id of the agent machine. :paramtype virtual_network_subnet_resource_id: str """ - super(AgentPool, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.count = count self.tier = tier self.os = os @@ -171,7 +167,7 @@ def __init__( self.provisioning_state = None -class AgentPoolListResult(msrest.serialization.Model): +class AgentPoolListResult(_serialization.Model): """The collection of agent pools. :ivar value: The collection value. @@ -181,29 +177,23 @@ class AgentPoolListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AgentPool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AgentPool]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["AgentPool"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AgentPool"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(AgentPoolListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AgentPoolQueueStatus(msrest.serialization.Model): +class AgentPoolQueueStatus(_serialization.Model): """The QueueStatus of Agent Pool. :ivar count: The number of pending runs in the queue. @@ -211,56 +201,45 @@ class AgentPoolQueueStatus(msrest.serialization.Model): """ _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, + "count": {"key": "count", "type": "int"}, } - def __init__( - self, - *, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, count: Optional[int] = None, **kwargs): """ :keyword count: The number of pending runs in the queue. :paramtype count: int """ - super(AgentPoolQueueStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.count = count -class AgentPoolUpdateParameters(msrest.serialization.Model): +class AgentPoolUpdateParameters(_serialization.Model): """The parameters for updating an agent pool. - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] :ivar count: The count of agent machine. :vartype count: int """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'count': {'key': 'properties.count', 'type': 'int'}, + "tags": {"key": "tags", "type": "{str}"}, + "count": {"key": "properties.count", "type": "int"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - count: Optional[int] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, count: Optional[int] = None, **kwargs): """ - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] :keyword count: The count of agent machine. :paramtype count: int """ - super(AgentPoolUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.count = count -class AgentProperties(msrest.serialization.Model): +class AgentProperties(_serialization.Model): """The properties that determine the run agent configuration. :ivar cpu: The CPU configuration in terms of number of cores required for the run. @@ -268,31 +247,26 @@ class AgentProperties(msrest.serialization.Model): """ _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'int'}, + "cpu": {"key": "cpu", "type": "int"}, } - def __init__( - self, - *, - cpu: Optional[int] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[int] = None, **kwargs): """ :keyword cpu: The CPU configuration in terms of number of cores required for the run. :paramtype cpu: int """ - super(AgentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu -class Argument(msrest.serialization.Model): +class Argument(_serialization.Model): """The properties of a run argument. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the argument. + :ivar name: The name of the argument. Required. :vartype name: str - :ivar value: Required. The value of the argument. + :ivar value: The value of the argument. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. @@ -300,47 +274,40 @@ class Argument(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the argument. + :keyword name: The name of the argument. Required. :paramtype name: str - :keyword value: Required. The value of the argument. + :keyword value: The value of the argument. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the argument represents a secret and want to be removed from build logs. :paramtype is_secret: bool """ - super(Argument, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class AuthInfo(msrest.serialization.Model): +class AuthInfo(_serialization.Model): """The authorization properties for accessing the source code repository. All required parameters must be populated in order to send to Azure. - :ivar token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenType - :ivar token: Required. The access token used to access the source control provider. + :ivar token: The access token used to access the source control provider. Required. :vartype token: str :ivar refresh_token: The refresh token used to refresh the access token. :vartype refresh_token: str @@ -351,22 +318,22 @@ class AuthInfo(msrest.serialization.Model): """ _validation = { - 'token_type': {'required': True}, - 'token': {'required': True}, + "token_type": {"required": True}, + "token": {"required": True}, } _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Union[str, "TokenType"], + token_type: Union[str, "_models.TokenType"], token: str, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -374,10 +341,10 @@ def __init__( **kwargs ): """ - :keyword token_type: Required. The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Required. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenType - :keyword token: Required. The access token used to access the source control provider. + :keyword token: The access token used to access the source control provider. Required. :paramtype token: str :keyword refresh_token: The refresh token used to refresh the access token. :paramtype refresh_token: str @@ -386,7 +353,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -394,10 +361,10 @@ def __init__( self.expires_in = expires_in -class AuthInfoUpdateParameters(msrest.serialization.Model): +class AuthInfoUpdateParameters(_serialization.Model): """The authorization properties for accessing the source code repository. - :ivar token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :ivar token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :vartype token_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenType :ivar token: The access token used to access the source control provider. :vartype token: str @@ -410,17 +377,17 @@ class AuthInfoUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'token_type': {'key': 'tokenType', 'type': 'str'}, - 'token': {'key': 'token', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'expires_in': {'key': 'expiresIn', 'type': 'int'}, + "token_type": {"key": "tokenType", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "refresh_token": {"key": "refreshToken", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "expires_in": {"key": "expiresIn", "type": "int"}, } def __init__( self, *, - token_type: Optional[Union[str, "TokenType"]] = None, + token_type: Optional[Union[str, "_models.TokenType"]] = None, token: Optional[str] = None, refresh_token: Optional[str] = None, scope: Optional[str] = None, @@ -428,7 +395,7 @@ def __init__( **kwargs ): """ - :keyword token_type: The type of Auth token. Possible values include: "PAT", "OAuth". + :keyword token_type: The type of Auth token. Known values are: "PAT" and "OAuth". :paramtype token_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenType :keyword token: The access token used to access the source control provider. @@ -440,7 +407,7 @@ def __init__( :keyword expires_in: Time in seconds that the token remains valid. :paramtype expires_in: int """ - super(AuthInfoUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_type = token_type self.token = token self.refresh_token = refresh_token @@ -448,11 +415,10 @@ def __init__( self.expires_in = expires_in -class BaseImageDependency(msrest.serialization.Model): +class BaseImageDependency(_serialization.Model): """Properties that describe a base image dependency. - :ivar type: The type of the base image dependency. Possible values include: "BuildTime", - "RunTime". + :ivar type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageDependencyType :ivar registry: The registry login server. @@ -466,17 +432,17 @@ class BaseImageDependency(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "BaseImageDependencyType"]] = None, + type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, registry: Optional[str] = None, repository: Optional[str] = None, tag: Optional[str] = None, @@ -484,7 +450,7 @@ def __init__( **kwargs ): """ - :keyword type: The type of the base image dependency. Possible values include: "BuildTime", + :keyword type: The type of the base image dependency. Known values are: "BuildTime" and "RunTime". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageDependencyType @@ -497,7 +463,7 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(BaseImageDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.registry = registry self.repository = repository @@ -505,68 +471,68 @@ def __init__( self.digest = digest -class BaseImageTrigger(msrest.serialization.Model): +class BaseImageTrigger(_serialization.Model): """The trigger based on base image dependency. All required parameters must be populated in order to send to Azure. - :ivar base_image_trigger_type: Required. The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. + Required. Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTriggerType :ivar update_trigger_endpoint: The endpoint URL for receiving update triggers. :vartype update_trigger_endpoint: str - :ivar update_trigger_payload_type: Type of Payload body for Base image update triggers. - Possible values include: "Default", "Token". + :ivar update_trigger_payload_type: Type of Payload body for Base image update triggers. Known + values are: "Default" and "Token". :vartype update_trigger_payload_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.UpdateTriggerPayloadType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'base_image_trigger_type': {'required': True}, - 'name': {'required': True}, + "base_image_trigger_type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'update_trigger_endpoint': {'key': 'updateTriggerEndpoint', 'type': 'str'}, - 'update_trigger_payload_type': {'key': 'updateTriggerPayloadType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "update_trigger_endpoint": {"key": "updateTriggerEndpoint", "type": "str"}, + "update_trigger_payload_type": {"key": "updateTriggerPayloadType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - base_image_trigger_type: Union[str, "BaseImageTriggerType"], + base_image_trigger_type: Union[str, "_models.BaseImageTriggerType"], name: str, update_trigger_endpoint: Optional[str] = None, - update_trigger_payload_type: Optional[Union[str, "UpdateTriggerPayloadType"]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + update_trigger_payload_type: Optional[Union[str, "_models.UpdateTriggerPayloadType"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword base_image_trigger_type: Required. The type of the auto trigger for base image - dependency updates. Possible values include: "All", "Runtime". + :keyword base_image_trigger_type: The type of the auto trigger for base image dependency + updates. Required. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTriggerType :keyword update_trigger_endpoint: The endpoint URL for receiving update triggers. :paramtype update_trigger_endpoint: str :keyword update_trigger_payload_type: Type of Payload body for Base image update triggers. - Possible values include: "Default", "Token". + Known values are: "Default" and "Token". :paramtype update_trigger_payload_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.UpdateTriggerPayloadType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.update_trigger_endpoint = update_trigger_endpoint self.update_trigger_payload_type = update_trigger_payload_type @@ -574,67 +540,67 @@ def __init__( self.name = name -class BaseImageTriggerUpdateParameters(msrest.serialization.Model): +class BaseImageTriggerUpdateParameters(_serialization.Model): """The properties for updating base image dependency trigger. All required parameters must be populated in order to send to Azure. :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. - Possible values include: "All", "Runtime". + Known values are: "All" and "Runtime". :vartype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTriggerType :ivar update_trigger_endpoint: The endpoint URL for receiving update triggers. :vartype update_trigger_endpoint: str - :ivar update_trigger_payload_type: Type of Payload body for Base image update triggers. - Possible values include: "Default", "Token". + :ivar update_trigger_payload_type: Type of Payload body for Base image update triggers. Known + values are: "Default" and "Token". :vartype update_trigger_payload_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.UpdateTriggerPayloadType - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'base_image_trigger_type': {'key': 'baseImageTriggerType', 'type': 'str'}, - 'update_trigger_endpoint': {'key': 'updateTriggerEndpoint', 'type': 'str'}, - 'update_trigger_payload_type': {'key': 'updateTriggerPayloadType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "base_image_trigger_type": {"key": "baseImageTriggerType", "type": "str"}, + "update_trigger_endpoint": {"key": "updateTriggerEndpoint", "type": "str"}, + "update_trigger_payload_type": {"key": "updateTriggerPayloadType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - base_image_trigger_type: Optional[Union[str, "BaseImageTriggerType"]] = None, + base_image_trigger_type: Optional[Union[str, "_models.BaseImageTriggerType"]] = None, update_trigger_endpoint: Optional[str] = None, - update_trigger_payload_type: Optional[Union[str, "UpdateTriggerPayloadType"]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + update_trigger_payload_type: Optional[Union[str, "_models.UpdateTriggerPayloadType"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ :keyword base_image_trigger_type: The type of the auto trigger for base image dependency - updates. Possible values include: "All", "Runtime". + updates. Known values are: "All" and "Runtime". :paramtype base_image_trigger_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTriggerType :keyword update_trigger_endpoint: The endpoint URL for receiving update triggers. :paramtype update_trigger_endpoint: str :keyword update_trigger_payload_type: Type of Payload body for Base image update triggers. - Possible values include: "Default", "Token". + Known values are: "Default" and "Token". :paramtype update_trigger_payload_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.UpdateTriggerPayloadType - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(BaseImageTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_image_trigger_type = base_image_trigger_type self.update_trigger_endpoint = update_trigger_endpoint self.update_trigger_payload_type = update_trigger_payload_type @@ -642,7 +608,7 @@ def __init__( self.name = name -class Credentials(msrest.serialization.Model): +class Credentials(_serialization.Model): """The parameters that describes a set of credentials that will be used when a run is invoked. :ivar source_registry: Describes the credential parameters for accessing the source registry. @@ -657,15 +623,15 @@ class Credentials(msrest.serialization.Model): """ _attribute_map = { - 'source_registry': {'key': 'sourceRegistry', 'type': 'SourceRegistryCredentials'}, - 'custom_registries': {'key': 'customRegistries', 'type': '{CustomRegistryCredentials}'}, + "source_registry": {"key": "sourceRegistry", "type": "SourceRegistryCredentials"}, + "custom_registries": {"key": "customRegistries", "type": "{CustomRegistryCredentials}"}, } def __init__( self, *, - source_registry: Optional["SourceRegistryCredentials"] = None, - custom_registries: Optional[Dict[str, "CustomRegistryCredentials"]] = None, + source_registry: Optional["_models.SourceRegistryCredentials"] = None, + custom_registries: Optional[Dict[str, "_models.CustomRegistryCredentials"]] = None, **kwargs ): """ @@ -680,12 +646,12 @@ def __init__( :paramtype custom_registries: dict[str, ~azure.mgmt.containerregistry.v2019_06_01_preview.models.CustomRegistryCredentials] """ - super(Credentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_registry = source_registry self.custom_registries = custom_registries -class CustomRegistryCredentials(msrest.serialization.Model): +class CustomRegistryCredentials(_serialization.Model): """Describes the credentials that will be used to access a custom registry during a run. :ivar user_name: The username for logging into the custom registry. @@ -704,16 +670,16 @@ class CustomRegistryCredentials(msrest.serialization.Model): """ _attribute_map = { - 'user_name': {'key': 'userName', 'type': 'SecretObject'}, - 'password': {'key': 'password', 'type': 'SecretObject'}, - 'identity': {'key': 'identity', 'type': 'str'}, + "user_name": {"key": "userName", "type": "SecretObject"}, + "password": {"key": "password", "type": "SecretObject"}, + "identity": {"key": "identity", "type": "str"}, } def __init__( self, *, - user_name: Optional["SecretObject"] = None, - password: Optional["SecretObject"] = None, + user_name: Optional["_models.SecretObject"] = None, + password: Optional["_models.SecretObject"] = None, identity: Optional[str] = None, **kwargs ): @@ -732,21 +698,21 @@ def __init__( source of authentication used for accessing the registry. :paramtype identity: str """ - super(CustomRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.password = password self.identity = identity -class RunRequest(msrest.serialization.Model): +class RunRequest(_serialization.Model): """The request parameters for scheduling a run. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildRequest, EncodedTaskRunRequest, FileTaskRunRequest, TaskRunRequest All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -759,24 +725,29 @@ class RunRequest(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, - 'log_template': {'key': 'logTemplate', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, + "log_template": {"key": "logTemplate", "type": "str"}, } _subtype_map = { - 'type': {'DockerBuildRequest': 'DockerBuildRequest', 'EncodedTaskRunRequest': 'EncodedTaskRunRequest', 'FileTaskRunRequest': 'FileTaskRunRequest', 'TaskRunRequest': 'TaskRunRequest'} + "type": { + "DockerBuildRequest": "DockerBuildRequest", + "EncodedTaskRunRequest": "EncodedTaskRunRequest", + "FileTaskRunRequest": "FileTaskRunRequest", + "TaskRunRequest": "TaskRunRequest", + } } def __init__( self, *, - is_archive_enabled: Optional[bool] = False, + is_archive_enabled: bool = False, agent_pool_name: Optional[str] = None, log_template: Optional[str] = None, **kwargs @@ -791,19 +762,19 @@ def __init__( log artifact. :paramtype log_template: str """ - super(RunRequest, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.is_archive_enabled = is_archive_enabled self.agent_pool_name = agent_pool_name self.log_template = log_template -class DockerBuildRequest(RunRequest): +class DockerBuildRequest(RunRequest): # pylint: disable=too-many-instance-attributes """The parameters for a docker quick build. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -820,7 +791,7 @@ class DockerBuildRequest(RunRequest): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source location. + :ivar docker_file_path: The Docker file path relative to the source location. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -828,7 +799,7 @@ class DockerBuildRequest(RunRequest): :vartype arguments: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Argument] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: @@ -844,47 +815,47 @@ class DockerBuildRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'docker_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, - 'log_template': {'key': 'logTemplate', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"required": True}, + "docker_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, + "log_template": {"key": "logTemplate", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, docker_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, agent_pool_name: Optional[str] = None, log_template: Optional[str] = None, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + arguments: Optional[List["_models.Argument"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ @@ -904,7 +875,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source location. + :keyword docker_file_path: The Docker file path relative to the source location. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -912,7 +883,7 @@ def __init__( :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Argument] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. @@ -927,8 +898,10 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Credentials """ - super(DockerBuildRequest, self).__init__(is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs) - self.type = 'DockerBuildRequest' # type: str + super().__init__( + is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs + ) + self.type: str = "DockerBuildRequest" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -942,18 +915,18 @@ def __init__( self.credentials = credentials -class TaskStepProperties(msrest.serialization.Model): +class TaskStepProperties(_serialization.Model): """Base properties for any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStep, EncodedTaskStep, FileTaskStep. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStep, EncodedTaskStep, FileTaskStep 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 the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -966,28 +939,20 @@ class TaskStepProperties(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } - _subtype_map = { - 'type': {'Docker': 'DockerBuildStep', 'EncodedTask': 'EncodedTaskStep', 'FileTask': 'FileTaskStep'} - } + _subtype_map = {"type": {"Docker": "DockerBuildStep", "EncodedTask": "EncodedTaskStep", "FileTask": "FileTaskStep"}} - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -995,8 +960,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepProperties, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.base_image_dependencies = None self.context_path = context_path self.context_access_token = context_access_token @@ -1009,8 +974,8 @@ class DockerBuildStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1027,7 +992,7 @@ class DockerBuildStep(TaskStepProperties): :vartype is_push_enabled: bool :ivar no_cache: The value of this property indicates whether the image cache is enabled or not. :vartype no_cache: bool - :ivar docker_file_path: Required. The Docker file path relative to the source context. + :ivar docker_file_path: The Docker file path relative to the source context. Required. :vartype docker_file_path: str :ivar target: The name of the target build stage for the docker build. :vartype target: str @@ -1037,22 +1002,22 @@ class DockerBuildStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'docker_file_path': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "docker_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, } def __init__( @@ -1062,10 +1027,10 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = True, - no_cache: Optional[bool] = False, + is_push_enabled: bool = True, + no_cache: bool = False, target: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, **kwargs ): """ @@ -1082,7 +1047,7 @@ def __init__( :keyword no_cache: The value of this property indicates whether the image cache is enabled or not. :paramtype no_cache: bool - :keyword docker_file_path: Required. The Docker file path relative to the source context. + :keyword docker_file_path: The Docker file path relative to the source context. Required. :paramtype docker_file_path: str :keyword target: The name of the target build stage for the docker build. :paramtype target: str @@ -1090,8 +1055,8 @@ def __init__( step. :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Argument] """ - super(DockerBuildStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -1100,16 +1065,16 @@ def __init__( self.arguments = arguments -class TaskStepUpdateParameters(msrest.serialization.Model): +class TaskStepUpdateParameters(_serialization.Model): """Base properties for updating any task step. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DockerBuildStepUpdateParameters, EncodedTaskStepUpdateParameters, FileTaskStepUpdateParameters All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1119,26 +1084,24 @@ class TaskStepUpdateParameters(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, } _subtype_map = { - 'type': {'Docker': 'DockerBuildStepUpdateParameters', 'EncodedTask': 'EncodedTaskStepUpdateParameters', 'FileTask': 'FileTaskStepUpdateParameters'} + "type": { + "Docker": "DockerBuildStepUpdateParameters", + "EncodedTask": "EncodedTaskStepUpdateParameters", + "FileTask": "FileTaskStepUpdateParameters", + } } - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - **kwargs - ): + def __init__(self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs): """ :keyword context_path: The URL(absolute or relative) of the source context for the task step. :paramtype context_path: str @@ -1146,8 +1109,8 @@ def __init__( associated with the context for a step. :paramtype context_access_token: str """ - super(TaskStepUpdateParameters, self).__init__(**kwargs) - self.type = None # type: Optional[str] + super().__init__(**kwargs) + self.type: Optional[str] = None self.context_path = context_path self.context_access_token = context_access_token @@ -1157,8 +1120,8 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1182,19 +1145,19 @@ class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'image_names': {'key': 'imageNames', 'type': '[str]'}, - 'is_push_enabled': {'key': 'isPushEnabled', 'type': 'bool'}, - 'no_cache': {'key': 'noCache', 'type': 'bool'}, - 'docker_file_path': {'key': 'dockerFilePath', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'target': {'key': 'target', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "image_names": {"key": "imageNames", "type": "[str]"}, + "is_push_enabled": {"key": "isPushEnabled", "type": "bool"}, + "no_cache": {"key": "noCache", "type": "bool"}, + "docker_file_path": {"key": "dockerFilePath", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "target": {"key": "target", "type": "str"}, } def __init__( @@ -1206,7 +1169,7 @@ def __init__( is_push_enabled: Optional[bool] = None, no_cache: Optional[bool] = None, docker_file_path: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, target: Optional[str] = None, **kwargs ): @@ -1232,8 +1195,8 @@ def __init__( :keyword target: The name of the target build stage for the docker build. :paramtype target: str """ - super(DockerBuildStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'Docker' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "Docker" self.image_names = image_names self.is_push_enabled = is_push_enabled self.no_cache = no_cache @@ -1242,12 +1205,12 @@ def __init__( self.target = target -class EncodedTaskRunRequest(RunRequest): +class EncodedTaskRunRequest(RunRequest): # pylint: disable=too-many-instance-attributes """The parameters for a quick task run request. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -1257,8 +1220,8 @@ class EncodedTaskRunRequest(RunRequest): :ivar log_template: The template that describes the repository and tag information for run log artifact. :vartype log_template: str - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -1266,7 +1229,7 @@ class EncodedTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: @@ -1282,41 +1245,41 @@ class EncodedTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'encoded_task_content': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True}, + "encoded_task_content": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, - 'log_template': {'key': 'logTemplate', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, + "log_template": {"key": "logTemplate", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, encoded_task_content: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, agent_pool_name: Optional[str] = None, log_template: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ @@ -1328,8 +1291,8 @@ def __init__( :keyword log_template: The template that describes the repository and tag information for run log artifact. :paramtype log_template: str - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str @@ -1337,7 +1300,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. @@ -1352,8 +1315,10 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Credentials """ - super(EncodedTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs) - self.type = 'EncodedTaskRunRequest' # type: str + super().__init__( + is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs + ) + self.type: str = "EncodedTaskRunRequest" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1371,8 +1336,8 @@ class EncodedTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1382,8 +1347,8 @@ class EncodedTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :ivar encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :vartype encoded_task_content: str :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. :vartype encoded_values_content: str @@ -1392,19 +1357,19 @@ class EncodedTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'encoded_task_content': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "encoded_task_content": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1414,7 +1379,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1423,16 +1388,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword encoded_task_content: Required. Base64 encoded value of the template/definition file - content. + :keyword encoded_task_content: Base64 encoded value of the template/definition file content. + Required. :paramtype encoded_task_content: str :keyword encoded_values_content: Base64 encoded value of the parameters/values file content. :paramtype encoded_values_content: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] """ - super(EncodedTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values @@ -1443,8 +1408,8 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1460,16 +1425,16 @@ class EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'encoded_task_content': {'key': 'encodedTaskContent', 'type': 'str'}, - 'encoded_values_content': {'key': 'encodedValuesContent', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "encoded_task_content": {"key": "encodedTaskContent", "type": "str"}, + "encoded_values_content": {"key": "encodedValuesContent", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1479,7 +1444,7 @@ def __init__( context_access_token: Optional[str] = None, encoded_task_content: Optional[str] = None, encoded_values_content: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1495,14 +1460,14 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] """ - super(EncodedTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'EncodedTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "EncodedTask" self.encoded_task_content = encoded_task_content self.encoded_values_content = encoded_values_content self.values = values -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -1510,31 +1475,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -1545,15 +1505,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -1562,13 +1522,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -1577,19 +1537,19 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class FileTaskRunRequest(RunRequest): +class FileTaskRunRequest(RunRequest): # pylint: disable=too-many-instance-attributes """The request parameters for a scheduling run against a task file. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -1599,7 +1559,7 @@ class FileTaskRunRequest(RunRequest): :ivar log_template: The template that describes the repository and tag information for run log artifact. :vartype log_template: str - :ivar task_file_path: Required. The template/definition file path relative to the source. + :ivar task_file_path: The template/definition file path relative to the source. Required. :vartype task_file_path: str :ivar values_file_path: The values/parameters file path relative to the source. :vartype values_file_path: str @@ -1607,7 +1567,7 @@ class FileTaskRunRequest(RunRequest): :vartype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] :ivar timeout: Run timeout in seconds. :vartype timeout: int - :ivar platform: Required. The platform properties against which the run has to happen. + :ivar platform: The platform properties against which the run has to happen. Required. :vartype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :ivar agent_configuration: The machine configuration of the run agent. :vartype agent_configuration: @@ -1623,41 +1583,41 @@ class FileTaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'task_file_path': {'required': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - 'platform': {'required': True}, + "type": {"required": True}, + "task_file_path": {"required": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + "platform": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, - 'log_template': {'key': 'logTemplate', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'timeout': {'key': 'timeout', 'type': 'int'}, - 'platform': {'key': 'platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'agentConfiguration', 'type': 'AgentProperties'}, - 'source_location': {'key': 'sourceLocation', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'Credentials'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, + "log_template": {"key": "logTemplate", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "timeout": {"key": "timeout", "type": "int"}, + "platform": {"key": "platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "agentConfiguration", "type": "AgentProperties"}, + "source_location": {"key": "sourceLocation", "type": "str"}, + "credentials": {"key": "credentials", "type": "Credentials"}, } def __init__( self, *, task_file_path: str, - platform: "PlatformProperties", - is_archive_enabled: Optional[bool] = False, + platform: "_models.PlatformProperties", + is_archive_enabled: bool = False, agent_pool_name: Optional[str] = None, log_template: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, - timeout: Optional[int] = 3600, - agent_configuration: Optional["AgentProperties"] = None, + values: Optional[List["_models.SetValue"]] = None, + timeout: int = 3600, + agent_configuration: Optional["_models.AgentProperties"] = None, source_location: Optional[str] = None, - credentials: Optional["Credentials"] = None, + credentials: Optional["_models.Credentials"] = None, **kwargs ): """ @@ -1669,7 +1629,7 @@ def __init__( :keyword log_template: The template that describes the repository and tag information for run log artifact. :paramtype log_template: str - :keyword task_file_path: Required. The template/definition file path relative to the source. + :keyword task_file_path: The template/definition file path relative to the source. Required. :paramtype task_file_path: str :keyword values_file_path: The values/parameters file path relative to the source. :paramtype values_file_path: str @@ -1677,7 +1637,7 @@ def __init__( :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] :keyword timeout: Run timeout in seconds. :paramtype timeout: int - :keyword platform: Required. The platform properties against which the run has to happen. + :keyword platform: The platform properties against which the run has to happen. Required. :paramtype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties :keyword agent_configuration: The machine configuration of the run agent. @@ -1692,8 +1652,10 @@ def __init__( this run is invoked. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Credentials """ - super(FileTaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs) - self.type = 'FileTaskRunRequest' # type: str + super().__init__( + is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs + ) + self.type: str = "FileTaskRunRequest" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1711,8 +1673,8 @@ class FileTaskStep(TaskStepProperties): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar base_image_dependencies: List of base image dependencies for a step. :vartype base_image_dependencies: @@ -1722,8 +1684,8 @@ class FileTaskStep(TaskStepProperties): :ivar context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :vartype context_access_token: str - :ivar task_file_path: Required. The task template/definition file path relative to the source - context. + :ivar task_file_path: The task template/definition file path relative to the source context. + Required. :vartype task_file_path: str :ivar values_file_path: The task values/parameters file path relative to the source context. :vartype values_file_path: str @@ -1732,19 +1694,19 @@ class FileTaskStep(TaskStepProperties): """ _validation = { - 'type': {'required': True}, - 'base_image_dependencies': {'readonly': True}, - 'task_file_path': {'required': True}, + "type": {"required": True}, + "base_image_dependencies": {"readonly": True}, + "task_file_path": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'base_image_dependencies': {'key': 'baseImageDependencies', 'type': '[BaseImageDependency]'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "base_image_dependencies": {"key": "baseImageDependencies", "type": "[BaseImageDependency]"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1754,7 +1716,7 @@ def __init__( context_path: Optional[str] = None, context_access_token: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1763,16 +1725,16 @@ def __init__( :keyword context_access_token: The token (git PAT or SAS token of storage account blob) associated with the context for a step. :paramtype context_access_token: str - :keyword task_file_path: Required. The task template/definition file path relative to the - source context. + :keyword task_file_path: The task template/definition file path relative to the source context. + Required. :paramtype task_file_path: str :keyword values_file_path: The task values/parameters file path relative to the source context. :paramtype values_file_path: str :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] """ - super(FileTaskStep, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values @@ -1783,8 +1745,8 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the step.Constant filled by server. Possible values include: - "Docker", "FileTask", "EncodedTask". + :ivar type: The type of the step. Required. Known values are: "Docker", "FileTask", and + "EncodedTask". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.StepType :ivar context_path: The URL(absolute or relative) of the source context for the task step. :vartype context_path: str @@ -1800,16 +1762,16 @@ class FileTaskStepUpdateParameters(TaskStepUpdateParameters): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'context_access_token': {'key': 'contextAccessToken', 'type': 'str'}, - 'task_file_path': {'key': 'taskFilePath', 'type': 'str'}, - 'values_file_path': {'key': 'valuesFilePath', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, + "type": {"key": "type", "type": "str"}, + "context_path": {"key": "contextPath", "type": "str"}, + "context_access_token": {"key": "contextAccessToken", "type": "str"}, + "task_file_path": {"key": "taskFilePath", "type": "str"}, + "values_file_path": {"key": "valuesFilePath", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, } def __init__( @@ -1819,7 +1781,7 @@ def __init__( context_access_token: Optional[str] = None, task_file_path: Optional[str] = None, values_file_path: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, **kwargs ): """ @@ -1835,22 +1797,22 @@ def __init__( :keyword values: The collection of overridable values that can be passed when running a task. :paramtype values: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.SetValue] """ - super(FileTaskStepUpdateParameters, self).__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) - self.type = 'FileTask' # type: str + super().__init__(context_path=context_path, context_access_token=context_access_token, **kwargs) + self.type: str = "FileTask" self.task_file_path = task_file_path self.values_file_path = values_file_path self.values = values -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1863,10 +1825,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1874,8 +1836,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1883,8 +1845,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1895,14 +1857,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2019_06_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImageDescriptor(msrest.serialization.Model): +class ImageDescriptor(_serialization.Model): """Properties for a registry image. :ivar registry: The registry login server. @@ -1916,10 +1878,10 @@ class ImageDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'registry': {'key': 'registry', 'type': 'str'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'digest': {'key': 'digest', 'type': 'str'}, + "registry": {"key": "registry", "type": "str"}, + "repository": {"key": "repository", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "digest": {"key": "digest", "type": "str"}, } def __init__( @@ -1941,14 +1903,14 @@ def __init__( :keyword digest: The sha256-based digest of the image manifest. :paramtype digest: str """ - super(ImageDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry = registry self.repository = repository self.tag = tag self.digest = digest -class ImageUpdateTrigger(msrest.serialization.Model): +class ImageUpdateTrigger(_serialization.Model): """The image update trigger that caused a build. :ivar id: The unique ID of the trigger. @@ -1960,17 +1922,17 @@ class ImageUpdateTrigger(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'images': {'key': 'images', 'type': '[ImageDescriptor]'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "images": {"key": "images", "type": "[ImageDescriptor]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, - images: Optional[List["ImageDescriptor"]] = None, + images: Optional[List["_models.ImageDescriptor"]] = None, **kwargs ): """ @@ -1982,59 +1944,52 @@ def __init__( :paramtype images: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ImageDescriptor] """ - super(ImageUpdateTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.images = images -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class OverrideTaskStepProperties(msrest.serialization.Model): +class OverrideTaskStepProperties(_serialization.Model): """OverrideTaskStepProperties. :ivar context_path: The source context against which run has to be queued. @@ -2054,12 +2009,12 @@ class OverrideTaskStepProperties(msrest.serialization.Model): """ _attribute_map = { - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '[Argument]'}, - 'target': {'key': 'target', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[SetValue]'}, - 'update_trigger_token': {'key': 'updateTriggerToken', 'type': 'str'}, + "context_path": {"key": "contextPath", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "arguments": {"key": "arguments", "type": "[Argument]"}, + "target": {"key": "target", "type": "str"}, + "values": {"key": "values", "type": "[SetValue]"}, + "update_trigger_token": {"key": "updateTriggerToken", "type": "str"}, } def __init__( @@ -2067,9 +2022,9 @@ def __init__( *, context_path: Optional[str] = None, file: Optional[str] = None, - arguments: Optional[List["Argument"]] = None, + arguments: Optional[List["_models.Argument"]] = None, target: Optional[str] = None, - values: Optional[List["SetValue"]] = None, + values: Optional[List["_models.SetValue"]] = None, update_trigger_token: Optional[str] = None, **kwargs ): @@ -2089,7 +2044,7 @@ def __init__( the base image trigger webhook. :paramtype update_trigger_token: str """ - super(OverrideTaskStepProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.context_path = context_path self.file = file self.arguments = arguments @@ -2098,103 +2053,103 @@ def __init__( self.update_trigger_token = update_trigger_token -class PlatformProperties(msrest.serialization.Model): +class PlatformProperties(_serialization.Model): """The platform properties against which the run has to happen. All required parameters must be populated in order to send to Azure. - :ivar os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :ivar os: The operating system type required for the run. Required. Known values are: "Windows" + and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "386", "arm", + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", "386", "arm", and "arm64". :vartype architecture: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Variant """ _validation = { - 'os': {'required': True}, + "os": {"required": True}, } _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Union[str, "OS"], - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Union[str, "_models.OS"], + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: Required. The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Required. Known values are: + "Windows" and "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "386", - "arm", "arm64". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", "386", "arm", and + "arm64". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Variant """ - super(PlatformProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class PlatformUpdateParameters(msrest.serialization.Model): +class PlatformUpdateParameters(_serialization.Model): """The properties for updating the platform configuration. - :ivar os: The operating system type required for the run. Possible values include: "Windows", + :ivar os: The operating system type required for the run. Known values are: "Windows" and "Linux". :vartype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS - :ivar architecture: The OS architecture. Possible values include: "amd64", "x86", "386", "arm", + :ivar architecture: The OS architecture. Known values are: "amd64", "x86", "386", "arm", and "arm64". :vartype architecture: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Architecture - :ivar variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :ivar variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :vartype variant: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Variant """ _attribute_map = { - 'os': {'key': 'os', 'type': 'str'}, - 'architecture': {'key': 'architecture', 'type': 'str'}, - 'variant': {'key': 'variant', 'type': 'str'}, + "os": {"key": "os", "type": "str"}, + "architecture": {"key": "architecture", "type": "str"}, + "variant": {"key": "variant", "type": "str"}, } def __init__( self, *, - os: Optional[Union[str, "OS"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, - variant: Optional[Union[str, "Variant"]] = None, + os: Optional[Union[str, "_models.OS"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + variant: Optional[Union[str, "_models.Variant"]] = None, **kwargs ): """ - :keyword os: The operating system type required for the run. Possible values include: - "Windows", "Linux". + :keyword os: The operating system type required for the run. Known values are: "Windows" and + "Linux". :paramtype os: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OS - :keyword architecture: The OS architecture. Possible values include: "amd64", "x86", "386", - "arm", "arm64". + :keyword architecture: The OS architecture. Known values are: "amd64", "x86", "386", "arm", and + "arm64". :paramtype architecture: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Architecture - :keyword variant: Variant of the CPU. Possible values include: "v6", "v7", "v8". + :keyword variant: Variant of the CPU. Known values are: "v6", "v7", and "v8". :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Variant """ - super(PlatformUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.os = os self.architecture = architecture self.variant = variant -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2210,33 +2165,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class Run(ProxyResource): +class Run(ProxyResource): # pylint: disable=too-many-instance-attributes """Run resource properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2251,13 +2202,13 @@ class Run(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunStatus :ivar last_updated_time: The last updated time for the run. :vartype last_updated_time: ~datetime.datetime - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunType :ivar agent_pool_name: The dedicated agent pool for the run. :vartype agent_pool_name: str @@ -2300,8 +2251,8 @@ class Run(ProxyResource): :vartype update_trigger_token: str :ivar log_artifact: The image description for the log artifact. :vartype log_artifact: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ImageDescriptor - :ivar provisioning_state: The provisioning state of a run. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -2309,78 +2260,78 @@ class Run(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'run_error_message': {'readonly': True}, - 'log_artifact': {'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'}, - 'run_id': {'key': 'properties.runId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'run_type': {'key': 'properties.runType', 'type': 'str'}, - 'agent_pool_name': {'key': 'properties.agentPoolName', 'type': 'str'}, - 'create_time': {'key': 'properties.createTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'properties.finishTime', 'type': 'iso-8601'}, - 'output_images': {'key': 'properties.outputImages', 'type': '[ImageDescriptor]'}, - 'task': {'key': 'properties.task', 'type': 'str'}, - 'image_update_trigger': {'key': 'properties.imageUpdateTrigger', 'type': 'ImageUpdateTrigger'}, - 'source_trigger': {'key': 'properties.sourceTrigger', 'type': 'SourceTriggerDescriptor'}, - 'timer_trigger': {'key': 'properties.timerTrigger', 'type': 'TimerTriggerDescriptor'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'source_registry_auth': {'key': 'properties.sourceRegistryAuth', 'type': 'str'}, - 'custom_registries': {'key': 'properties.customRegistries', 'type': '[str]'}, - 'run_error_message': {'key': 'properties.runErrorMessage', 'type': 'str'}, - 'update_trigger_token': {'key': 'properties.updateTriggerToken', 'type': 'str'}, - 'log_artifact': {'key': 'properties.logArtifact', 'type': 'ImageDescriptor'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_archive_enabled': {'key': 'properties.isArchiveEnabled', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "run_error_message": {"readonly": True}, + "log_artifact": {"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"}, + "run_id": {"key": "properties.runId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "run_type": {"key": "properties.runType", "type": "str"}, + "agent_pool_name": {"key": "properties.agentPoolName", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "finish_time": {"key": "properties.finishTime", "type": "iso-8601"}, + "output_images": {"key": "properties.outputImages", "type": "[ImageDescriptor]"}, + "task": {"key": "properties.task", "type": "str"}, + "image_update_trigger": {"key": "properties.imageUpdateTrigger", "type": "ImageUpdateTrigger"}, + "source_trigger": {"key": "properties.sourceTrigger", "type": "SourceTriggerDescriptor"}, + "timer_trigger": {"key": "properties.timerTrigger", "type": "TimerTriggerDescriptor"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "source_registry_auth": {"key": "properties.sourceRegistryAuth", "type": "str"}, + "custom_registries": {"key": "properties.customRegistries", "type": "[str]"}, + "run_error_message": {"key": "properties.runErrorMessage", "type": "str"}, + "update_trigger_token": {"key": "properties.updateTriggerToken", "type": "str"}, + "log_artifact": {"key": "properties.logArtifact", "type": "ImageDescriptor"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_archive_enabled": {"key": "properties.isArchiveEnabled", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, run_id: Optional[str] = None, - status: Optional[Union[str, "RunStatus"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, last_updated_time: Optional[datetime.datetime] = None, - run_type: Optional[Union[str, "RunType"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, agent_pool_name: Optional[str] = None, create_time: Optional[datetime.datetime] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - output_images: Optional[List["ImageDescriptor"]] = None, + output_images: Optional[List["_models.ImageDescriptor"]] = None, task: Optional[str] = None, - image_update_trigger: Optional["ImageUpdateTrigger"] = None, - source_trigger: Optional["SourceTriggerDescriptor"] = None, - timer_trigger: Optional["TimerTriggerDescriptor"] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, + image_update_trigger: Optional["_models.ImageUpdateTrigger"] = None, + source_trigger: Optional["_models.SourceTriggerDescriptor"] = None, + timer_trigger: Optional["_models.TimerTriggerDescriptor"] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, source_registry_auth: Optional[str] = None, custom_registries: Optional[List[str]] = None, update_trigger_token: Optional[str] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - is_archive_enabled: Optional[bool] = False, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + is_archive_enabled: bool = False, **kwargs ): """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunStatus :keyword last_updated_time: The last updated time for the run. :paramtype last_updated_time: ~datetime.datetime - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunType :keyword agent_pool_name: The dedicated agent pool for the run. :paramtype agent_pool_name: str @@ -2419,14 +2370,14 @@ def __init__( :paramtype custom_registries: list[str] :keyword update_trigger_token: The update trigger token passed for the Run. :paramtype update_trigger_token: str - :keyword provisioning_state: The provisioning state of a run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :keyword provisioning_state: The provisioning state of a run. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :paramtype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(Run, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.status = status self.last_updated_time = last_updated_time @@ -2451,16 +2402,16 @@ def __init__( self.is_archive_enabled = is_archive_enabled -class RunFilter(msrest.serialization.Model): +class RunFilter(_serialization.Model): """Properties that are enabled for Odata querying on runs. :ivar run_id: The unique identifier for the run. :vartype run_id: str - :ivar run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :ivar run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", and + "AutoRun". :vartype run_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunType - :ivar status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :ivar status: The current status of the run. Known values are: "Queued", "Started", "Running", + "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunStatus :ivar create_time: The create time for a run. :vartype create_time: ~datetime.datetime @@ -2479,23 +2430,23 @@ class RunFilter(msrest.serialization.Model): """ _attribute_map = { - 'run_id': {'key': 'runId', 'type': 'str'}, - 'run_type': {'key': 'runType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'create_time': {'key': 'createTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'output_image_manifests': {'key': 'outputImageManifests', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'task_name': {'key': 'taskName', 'type': 'str'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, + "run_id": {"key": "runId", "type": "str"}, + "run_type": {"key": "runType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "create_time": {"key": "createTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "output_image_manifests": {"key": "outputImageManifests", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "task_name": {"key": "taskName", "type": "str"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, } def __init__( self, *, run_id: Optional[str] = None, - run_type: Optional[Union[str, "RunType"]] = None, - status: Optional[Union[str, "RunStatus"]] = None, + run_type: Optional[Union[str, "_models.RunType"]] = None, + status: Optional[Union[str, "_models.RunStatus"]] = None, create_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, output_image_manifests: Optional[str] = None, @@ -2507,11 +2458,11 @@ def __init__( """ :keyword run_id: The unique identifier for the run. :paramtype run_id: str - :keyword run_type: The type of run. Possible values include: "QuickBuild", "QuickRun", - "AutoBuild", "AutoRun". + :keyword run_type: The type of run. Known values are: "QuickBuild", "QuickRun", "AutoBuild", + and "AutoRun". :paramtype run_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunType - :keyword status: The current status of the run. Possible values include: "Queued", "Started", - "Running", "Succeeded", "Failed", "Canceled", "Error", "Timeout". + :keyword status: The current status of the run. Known values are: "Queued", "Started", + "Running", "Succeeded", "Failed", "Canceled", "Error", and "Timeout". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunStatus :keyword create_time: The create time for a run. :paramtype create_time: ~datetime.datetime @@ -2528,7 +2479,7 @@ def __init__( :keyword agent_pool_name: The name of the agent pool that the run corresponds to. :paramtype agent_pool_name: str """ - super(RunFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.run_id = run_id self.run_type = run_type self.status = status @@ -2540,7 +2491,7 @@ def __init__( self.agent_pool_name = agent_pool_name -class RunGetLogResult(msrest.serialization.Model): +class RunGetLogResult(_serialization.Model): """The result of get log link operation. :ivar log_link: The link to logs for a run on a azure container registry. @@ -2550,17 +2501,11 @@ class RunGetLogResult(msrest.serialization.Model): """ _attribute_map = { - 'log_link': {'key': 'logLink', 'type': 'str'}, - 'log_artifact_link': {'key': 'logArtifactLink', 'type': 'str'}, + "log_link": {"key": "logLink", "type": "str"}, + "log_artifact_link": {"key": "logArtifactLink", "type": "str"}, } - def __init__( - self, - *, - log_link: Optional[str] = None, - log_artifact_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, log_link: Optional[str] = None, log_artifact_link: Optional[str] = None, **kwargs): """ :keyword log_link: The link to logs for a run on a azure container registry. :paramtype log_link: str @@ -2568,12 +2513,12 @@ def __init__( registry. :paramtype log_artifact_link: str """ - super(RunGetLogResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_link = log_link self.log_artifact_link = log_artifact_link -class RunListResult(msrest.serialization.Model): +class RunListResult(_serialization.Model): """Collection of runs. :ivar value: The collection value. @@ -2583,29 +2528,23 @@ class RunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Run]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Run]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Run"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Run"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(RunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RunUpdateParameters(msrest.serialization.Model): +class RunUpdateParameters(_serialization.Model): """The set of run properties that can be updated. :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. @@ -2613,24 +2552,19 @@ class RunUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_archive_enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs): """ :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. :paramtype is_archive_enabled: bool """ - super(RunUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_archive_enabled = is_archive_enabled -class SecretObject(msrest.serialization.Model): +class SecretObject(_serialization.Model): """Describes the properties of a secret object value. :ivar value: The value of the secret. The format of this value will be determined @@ -2639,21 +2573,17 @@ class SecretObject(msrest.serialization.Model): :vartype value: str :ivar type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque", "Vaultsecret". + interpreted. Known values are: "Opaque" and "Vaultsecret". :vartype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SecretObjectType """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( - self, - *, - value: Optional[str] = None, - type: Optional[Union[str, "SecretObjectType"]] = None, - **kwargs + self, *, value: Optional[str] = None, type: Optional[Union[str, "_models.SecretObjectType"]] = None, **kwargs ): """ :keyword value: The value of the secret. The format of this value will be determined @@ -2662,71 +2592,64 @@ def __init__( :paramtype value: str :keyword type: The type of the secret object which determines how the value of the secret object has to be - interpreted. Possible values include: "Opaque", "Vaultsecret". + interpreted. Known values are: "Opaque" and "Vaultsecret". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SecretObjectType """ - super(SecretObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.type = type -class SetValue(msrest.serialization.Model): +class SetValue(_serialization.Model): """The properties of a overridable value that can be passed to a task template. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the overridable value. + :ivar name: The name of the overridable value. Required. :vartype name: str - :ivar value: Required. The overridable value. + :ivar value: The overridable value. Required. :vartype value: str :ivar is_secret: Flag to indicate whether the value represents a secret or not. :vartype is_secret: bool """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'is_secret': {'key': 'isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "is_secret": {"key": "isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: str, - value: str, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, value: str, is_secret: bool = False, **kwargs): """ - :keyword name: Required. The name of the overridable value. + :keyword name: The name of the overridable value. Required. :paramtype name: str - :keyword value: Required. The overridable value. + :keyword value: The overridable value. Required. :paramtype value: str :keyword is_secret: Flag to indicate whether the value represents a secret or not. :paramtype is_secret: bool """ - super(SetValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.is_secret = is_secret -class SourceProperties(msrest.serialization.Model): +class SourceProperties(_serialization.Model): """The properties of the source code repository. All required parameters must be populated in order to send to Azure. - :ivar source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceControlType - :ivar repository_url: Required. The full URL to the source code repository. + :ivar repository_url: The full URL to the source code repository. Required. :vartype repository_url: str :ivar branch: The branch name of the source code. :vartype branch: str @@ -2738,32 +2661,32 @@ class SourceProperties(msrest.serialization.Model): """ _validation = { - 'source_control_type': {'required': True}, - 'repository_url': {'required': True}, + "source_control_type": {"required": True}, + "repository_url": {"required": True}, } _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfo'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfo"}, } def __init__( self, *, - source_control_type: Union[str, "SourceControlType"], + source_control_type: Union[str, "_models.SourceControlType"], repository_url: str, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfo"] = None, + source_control_auth_properties: Optional["_models.AuthInfo"] = None, **kwargs ): """ - :keyword source_control_type: Required. The type of source control service. Possible values - include: "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Required. Known values are: + "Github" and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceControlType - :keyword repository_url: Required. The full URL to the source code repository. + :keyword repository_url: The full URL to the source code repository. Required. :paramtype repository_url: str :keyword branch: The branch name of the source code. :paramtype branch: str @@ -2773,107 +2696,102 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AuthInfo """ - super(SourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceRegistryCredentials(msrest.serialization.Model): +class SourceRegistryCredentials(_serialization.Model): """Describes the credential parameters for accessing the source registry. :ivar login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :vartype login_mode: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceRegistryLoginMode """ _attribute_map = { - 'login_mode': {'key': 'loginMode', 'type': 'str'}, + "login_mode": {"key": "loginMode", "type": "str"}, } - def __init__( - self, - *, - login_mode: Optional[Union[str, "SourceRegistryLoginMode"]] = None, - **kwargs - ): + def __init__(self, *, login_mode: Optional[Union[str, "_models.SourceRegistryLoginMode"]] = None, **kwargs): """ :keyword login_mode: The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. These credentials will be used to login to - the source registry during the run. Possible values include: "None", "Default". + the source registry during the run. Known values are: "None" and "Default". :paramtype login_mode: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceRegistryLoginMode """ - super(SourceRegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.login_mode = login_mode -class SourceTrigger(msrest.serialization.Model): +class SourceTrigger(_serialization.Model): """The properties of a source based trigger. All required parameters must be populated in order to send to Azure. - :ivar source_repository: Required. The properties that describes the source(code) for the task. + :ivar source_repository: The properties that describes the source(code) for the task. Required. :vartype source_repository: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceProperties - :ivar source_trigger_events: Required. The source event corresponding to the trigger. + :ivar source_trigger_events: The source event corresponding to the trigger. Required. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'source_repository': {'required': True}, - 'source_trigger_events': {'required': True}, - 'name': {'required': True}, + "source_repository": {"required": True}, + "source_trigger_events": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceProperties'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceProperties"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - source_repository: "SourceProperties", - source_trigger_events: List[Union[str, "SourceTriggerEvent"]], + source_repository: "_models.SourceProperties", + source_trigger_events: List[Union[str, "_models.SourceTriggerEvent"]], name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword source_repository: Required. The properties that describes the source(code) for the - task. + :keyword source_repository: The properties that describes the source(code) for the task. + Required. :paramtype source_repository: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceProperties - :keyword source_trigger_events: Required. The source event corresponding to the trigger. + :keyword source_trigger_events: The source event corresponding to the trigger. Required. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceTriggerDescriptor(msrest.serialization.Model): +class SourceTriggerDescriptor(_serialization.Model): """The source trigger that caused a run. :ivar id: The unique ID of the trigger. @@ -2893,19 +2811,19 @@ class SourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_type': {'key': 'eventType', 'type': 'str'}, - 'commit_id': {'key': 'commitId', 'type': 'str'}, - 'pull_request_id': {'key': 'pullRequestId', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch_name': {'key': 'branchName', 'type': 'str'}, - 'provider_type': {'key': 'providerType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "event_type": {"key": "eventType", "type": "str"}, + "commit_id": {"key": "commitId", "type": "str"}, + "pull_request_id": {"key": "pullRequestId", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch_name": {"key": "branchName", "type": "str"}, + "provider_type": {"key": "providerType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin event_type: Optional[str] = None, commit_id: Optional[str] = None, pull_request_id: Optional[str] = None, @@ -2930,7 +2848,7 @@ def __init__( :keyword provider_type: The source control provider type. :paramtype provider_type: str """ - super(SourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.event_type = event_type self.commit_id = commit_id @@ -2940,7 +2858,7 @@ def __init__( self.provider_type = provider_type -class SourceTriggerUpdateParameters(msrest.serialization.Model): +class SourceTriggerUpdateParameters(_serialization.Model): """The properties for updating a source based trigger. All required parameters must be populated in order to send to Azure. @@ -2951,30 +2869,30 @@ class SourceTriggerUpdateParameters(msrest.serialization.Model): :ivar source_trigger_events: The source event corresponding to the trigger. :vartype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceTriggerEvent] - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'source_repository': {'key': 'sourceRepository', 'type': 'SourceUpdateParameters'}, - 'source_trigger_events': {'key': 'sourceTriggerEvents', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "source_repository": {"key": "sourceRepository", "type": "SourceUpdateParameters"}, + "source_trigger_events": {"key": "sourceTriggerEvents", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - source_repository: Optional["SourceUpdateParameters"] = None, - source_trigger_events: Optional[List[Union[str, "SourceTriggerEvent"]]] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + source_repository: Optional["_models.SourceUpdateParameters"] = None, + source_trigger_events: Optional[List[Union[str, "_models.SourceTriggerEvent"]]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ @@ -2984,24 +2902,24 @@ def __init__( :keyword source_trigger_events: The source event corresponding to the trigger. :paramtype source_trigger_events: list[str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceTriggerEvent] - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(SourceTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_repository = source_repository self.source_trigger_events = source_trigger_events self.status = status self.name = name -class SourceUpdateParameters(msrest.serialization.Model): +class SourceUpdateParameters(_serialization.Model): """The properties for updating the source code repository. - :ivar source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :ivar source_control_type: The type of source control service. Known values are: "Github" and + "VisualStudioTeamService". :vartype source_control_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceControlType :ivar repository_url: The full URL to the source code repository. @@ -3016,24 +2934,24 @@ class SourceUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'source_control_type': {'key': 'sourceControlType', 'type': 'str'}, - 'repository_url': {'key': 'repositoryUrl', 'type': 'str'}, - 'branch': {'key': 'branch', 'type': 'str'}, - 'source_control_auth_properties': {'key': 'sourceControlAuthProperties', 'type': 'AuthInfoUpdateParameters'}, + "source_control_type": {"key": "sourceControlType", "type": "str"}, + "repository_url": {"key": "repositoryUrl", "type": "str"}, + "branch": {"key": "branch", "type": "str"}, + "source_control_auth_properties": {"key": "sourceControlAuthProperties", "type": "AuthInfoUpdateParameters"}, } def __init__( self, *, - source_control_type: Optional[Union[str, "SourceControlType"]] = None, + source_control_type: Optional[Union[str, "_models.SourceControlType"]] = None, repository_url: Optional[str] = None, branch: Optional[str] = None, - source_control_auth_properties: Optional["AuthInfoUpdateParameters"] = None, + source_control_auth_properties: Optional["_models.AuthInfoUpdateParameters"] = None, **kwargs ): """ - :keyword source_control_type: The type of source control service. Possible values include: - "Github", "VisualStudioTeamService". + :keyword source_control_type: The type of source control service. Known values are: "Github" + and "VisualStudioTeamService". :paramtype source_control_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceControlType :keyword repository_url: The full URL to the source code repository. @@ -3046,14 +2964,14 @@ def __init__( :paramtype source_control_auth_properties: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AuthInfoUpdateParameters """ - super(SourceUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_control_type = source_control_type self.repository_url = repository_url self.branch = branch self.source_control_auth_properties = source_control_auth_properties -class SourceUploadDefinition(msrest.serialization.Model): +class SourceUploadDefinition(_serialization.Model): """The properties of a response to source upload request. :ivar upload_url: The URL where the client can upload the source. @@ -3064,17 +2982,11 @@ class SourceUploadDefinition(msrest.serialization.Model): """ _attribute_map = { - 'upload_url': {'key': 'uploadUrl', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, + "upload_url": {"key": "uploadUrl", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, } - def __init__( - self, - *, - upload_url: Optional[str] = None, - relative_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, upload_url: Optional[str] = None, relative_path: Optional[str] = None, **kwargs): """ :keyword upload_url: The URL where the client can upload the source. :paramtype upload_url: str @@ -3082,26 +2994,26 @@ def __init__( queue build request. :paramtype relative_path: str """ - super(SourceUploadDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.upload_url = upload_url self.relative_path = relative_path -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -3109,44 +3021,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -3155,92 +3067,92 @@ def __init__( self.last_modified_at = last_modified_at -class Task(Resource): - """The task that has the ARM resource and task properties. -The task will have all information to schedule a run against it. - - 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: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. - :vartype location: str - :ivar tags: A set of tags. The tags of the resource. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties - :ivar provisioning_state: The provisioning state of the task. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState - :ivar creation_date: The creation date of task. - :vartype creation_date: ~datetime.datetime - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStatus - :ivar platform: The platform properties against which the run has to happen. - :vartype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties - :ivar agent_configuration: The machine configuration of the run agent. - :vartype agent_configuration: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentProperties - :ivar agent_pool_name: The dedicated agent pool for the task. - :vartype agent_pool_name: str - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :ivar step: The properties of a task step. - :vartype step: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStepProperties - :ivar trigger: The properties that describe all triggers for the task. - :vartype trigger: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerProperties - :ivar credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :vartype credentials: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Credentials - :ivar log_template: The template that describes the repository and tag information for run log - artifact. - :vartype log_template: str - :ivar is_system_task: The value of this property indicates whether the task resource is system - task or not. - :vartype is_system_task: bool +class Task(Resource): # pylint: disable=too-many-instance-attributes + """The task that has the ARM resource and task properties. + The task will have all information to schedule a run against it. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties + :ivar provisioning_state: The provisioning state of the task. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :ivar creation_date: The creation date of task. + :vartype creation_date: ~datetime.datetime + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStatus + :ivar platform: The platform properties against which the run has to happen. + :vartype platform: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.PlatformProperties + :ivar agent_configuration: The machine configuration of the run agent. + :vartype agent_configuration: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentProperties + :ivar agent_pool_name: The dedicated agent pool for the task. + :vartype agent_pool_name: str + :ivar timeout: Run timeout in seconds. + :vartype timeout: int + :ivar step: The properties of a task step. + :vartype step: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStepProperties + :ivar trigger: The properties that describe all triggers for the task. + :vartype trigger: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerProperties + :ivar credentials: The properties that describes a set of credentials that will be used when + this run is invoked. + :vartype credentials: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Credentials + :ivar log_template: The template that describes the repository and tag information for run log + artifact. + :vartype log_template: str + :ivar is_system_task: The value of this property indicates whether the task resource is system + task or not. + :vartype is_system_task: bool """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'timeout': {'maximum': 28800, 'minimum': 300}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformProperties'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'agent_pool_name': {'key': 'properties.agentPoolName', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerProperties'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, - 'log_template': {'key': 'properties.logTemplate', 'type': 'str'}, - 'is_system_task': {'key': 'properties.isSystemTask', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "creation_date": {"readonly": True}, + "timeout": {"maximum": 28800, "minimum": 300}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformProperties"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "agent_pool_name": {"key": "properties.agentPoolName", "type": "str"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepProperties"}, + "trigger": {"key": "properties.trigger", "type": "TriggerProperties"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, + "log_template": {"key": "properties.logTemplate", "type": "str"}, + "is_system_task": {"key": "properties.isSystemTask", "type": "bool"}, } def __init__( @@ -3248,29 +3160,29 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformProperties"] = None, - agent_configuration: Optional["AgentProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformProperties"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, agent_pool_name: Optional[str] = None, - timeout: Optional[int] = 3600, - step: Optional["TaskStepProperties"] = None, - trigger: Optional["TriggerProperties"] = None, - credentials: Optional["Credentials"] = None, + timeout: int = 3600, + step: Optional["_models.TaskStepProperties"] = None, + trigger: Optional["_models.TriggerProperties"] = None, + credentials: Optional["_models.Credentials"] = None, log_template: Optional[str] = None, - is_system_task: Optional[bool] = False, + is_system_task: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: @@ -3296,7 +3208,7 @@ def __init__( system task or not. :paramtype is_system_task: bool """ - super(Task, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.identity = identity self.provisioning_state = None self.creation_date = None @@ -3312,7 +3224,7 @@ def __init__( self.is_system_task = is_system_task -class TaskListResult(msrest.serialization.Model): +class TaskListResult(_serialization.Model): """The collection of tasks. :ivar value: The collection value. @@ -3322,87 +3234,81 @@ class TaskListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Task]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Task]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Task"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Task"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(TaskListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link class TaskRun(ProxyResource): - """The task run that has the ARM resource and properties. -The task run will have the information of request and result of a run. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties - :ivar location: The location of the resource. - :vartype location: str - :ivar provisioning_state: The provisioning state of this task run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState - :ivar run_request: The request (parameters) for the run. - :vartype run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest - :ivar run_result: The result of this task run. - :vartype run_result: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run - :ivar force_update_tag: How the run should be forced to rerun even if the run request - configuration has not changed. - :vartype force_update_tag: str + """The task run that has the ARM resource and properties. + The task run will have the information of request and result of a run. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SystemData + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties + :ivar location: The location of the resource. + :vartype location: str + :ivar provisioning_state: The provisioning state of this task run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :ivar run_request: The request (parameters) for the run. + :vartype run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest + :ivar run_result: The result of this task run. + :vartype run_result: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run + :ivar force_update_tag: How the run should be forced to rerun even if the run request + configuration has not changed. + :vartype force_update_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'run_result': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "run_result": {"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'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'run_request': {'key': 'properties.runRequest', 'type': 'RunRequest'}, - 'run_result': {'key': 'properties.runResult', 'type': 'Run'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "run_request": {"key": "properties.runRequest", "type": "RunRequest"}, + "run_result": {"key": "properties.runResult", "type": "Run"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, location: Optional[str] = None, - run_request: Optional["RunRequest"] = None, + run_request: Optional["_models.RunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -3418,7 +3324,7 @@ def __init__( configuration has not changed. :paramtype force_update_tag: str """ - super(TaskRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.location = location self.provisioning_state = None @@ -3427,7 +3333,7 @@ def __init__( self.force_update_tag = force_update_tag -class TaskRunListResult(msrest.serialization.Model): +class TaskRunListResult(_serialization.Model): """The collection of task runs. :ivar value: The collection value. @@ -3437,24 +3343,18 @@ class TaskRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[TaskRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TaskRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TaskRun"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TaskRun"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ - super(TaskRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -3464,7 +3364,7 @@ class TaskRunRequest(RunRequest): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of the run request.Constant filled by server. + :ivar type: The type of the run request. Required. :vartype type: str :ivar is_archive_enabled: The value that indicates whether archiving is enabled for the run or not. @@ -3474,7 +3374,7 @@ class TaskRunRequest(RunRequest): :ivar log_template: The template that describes the repository and tag information for run log artifact. :vartype log_template: str - :ivar task_id: Required. The resource ID of task against which run has to be queued. + :ivar task_id: The resource ID of task against which run has to be queued. Required. :vartype task_id: str :ivar override_task_step_properties: Set of overridable parameters that can be passed when running a Task. @@ -3483,27 +3383,27 @@ class TaskRunRequest(RunRequest): """ _validation = { - 'type': {'required': True}, - 'task_id': {'required': True}, + "type": {"required": True}, + "task_id": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_archive_enabled': {'key': 'isArchiveEnabled', 'type': 'bool'}, - 'agent_pool_name': {'key': 'agentPoolName', 'type': 'str'}, - 'log_template': {'key': 'logTemplate', 'type': 'str'}, - 'task_id': {'key': 'taskId', 'type': 'str'}, - 'override_task_step_properties': {'key': 'overrideTaskStepProperties', 'type': 'OverrideTaskStepProperties'}, + "type": {"key": "type", "type": "str"}, + "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, + "agent_pool_name": {"key": "agentPoolName", "type": "str"}, + "log_template": {"key": "logTemplate", "type": "str"}, + "task_id": {"key": "taskId", "type": "str"}, + "override_task_step_properties": {"key": "overrideTaskStepProperties", "type": "OverrideTaskStepProperties"}, } def __init__( self, *, task_id: str, - is_archive_enabled: Optional[bool] = False, + is_archive_enabled: bool = False, agent_pool_name: Optional[str] = None, log_template: Optional[str] = None, - override_task_step_properties: Optional["OverrideTaskStepProperties"] = None, + override_task_step_properties: Optional["_models.OverrideTaskStepProperties"] = None, **kwargs ): """ @@ -3515,27 +3415,29 @@ def __init__( :keyword log_template: The template that describes the repository and tag information for run log artifact. :paramtype log_template: str - :keyword task_id: Required. The resource ID of task against which run has to be queued. + :keyword task_id: The resource ID of task against which run has to be queued. Required. :paramtype task_id: str :keyword override_task_step_properties: Set of overridable parameters that can be passed when running a Task. :paramtype override_task_step_properties: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.OverrideTaskStepProperties """ - super(TaskRunRequest, self).__init__(is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs) - self.type = 'TaskRunRequest' # type: str + super().__init__( + is_archive_enabled=is_archive_enabled, agent_pool_name=agent_pool_name, log_template=log_template, **kwargs + ) + self.type: str = "TaskRunRequest" self.task_id = task_id self.override_task_step_properties = override_task_step_properties -class TaskRunUpdateParameters(msrest.serialization.Model): +class TaskRunUpdateParameters(_serialization.Model): """The parameters for updating a task run. :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties :ivar location: The location of the resource. :vartype location: str - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] :ivar run_request: The request (parameters) for the new run. :vartype run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest @@ -3545,20 +3447,20 @@ class TaskRunUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'run_request': {'key': 'properties.runRequest', 'type': 'RunRequest'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "run_request": {"key": "properties.runRequest", "type": "RunRequest"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - run_request: Optional["RunRequest"] = None, + run_request: Optional["_models.RunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -3568,7 +3470,7 @@ def __init__( ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties :keyword location: The location of the resource. :paramtype location: str - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] :keyword run_request: The request (parameters) for the new run. :paramtype run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest @@ -3576,7 +3478,7 @@ def __init__( configuration has not changed. :paramtype force_update_tag: str """ - super(TaskRunUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.location = location self.tags = tags @@ -3584,14 +3486,14 @@ def __init__( self.force_update_tag = force_update_tag -class TaskUpdateParameters(msrest.serialization.Model): +class TaskUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a task. :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The ARM resource tags. + :ivar tags: The ARM resource tags. :vartype tags: dict[str, str] - :ivar status: The current status of task. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of task. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStatus :ivar platform: The platform properties against which the run has to happen. :vartype platform: @@ -3618,32 +3520,32 @@ class TaskUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'platform': {'key': 'properties.platform', 'type': 'PlatformUpdateParameters'}, - 'agent_configuration': {'key': 'properties.agentConfiguration', 'type': 'AgentProperties'}, - 'agent_pool_name': {'key': 'properties.agentPoolName', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'int'}, - 'step': {'key': 'properties.step', 'type': 'TaskStepUpdateParameters'}, - 'trigger': {'key': 'properties.trigger', 'type': 'TriggerUpdateParameters'}, - 'credentials': {'key': 'properties.credentials', 'type': 'Credentials'}, - 'log_template': {'key': 'properties.logTemplate', 'type': 'str'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "platform": {"key": "properties.platform", "type": "PlatformUpdateParameters"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentProperties"}, + "agent_pool_name": {"key": "properties.agentPoolName", "type": "str"}, + "timeout": {"key": "properties.timeout", "type": "int"}, + "step": {"key": "properties.step", "type": "TaskStepUpdateParameters"}, + "trigger": {"key": "properties.trigger", "type": "TriggerUpdateParameters"}, + "credentials": {"key": "properties.credentials", "type": "Credentials"}, + "log_template": {"key": "properties.logTemplate", "type": "str"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "TaskStatus"]] = None, - platform: Optional["PlatformUpdateParameters"] = None, - agent_configuration: Optional["AgentProperties"] = None, + status: Optional[Union[str, "_models.TaskStatus"]] = None, + platform: Optional["_models.PlatformUpdateParameters"] = None, + agent_configuration: Optional["_models.AgentProperties"] = None, agent_pool_name: Optional[str] = None, timeout: Optional[int] = None, - step: Optional["TaskStepUpdateParameters"] = None, - trigger: Optional["TriggerUpdateParameters"] = None, - credentials: Optional["Credentials"] = None, + step: Optional["_models.TaskStepUpdateParameters"] = None, + trigger: Optional["_models.TriggerUpdateParameters"] = None, + credentials: Optional["_models.Credentials"] = None, log_template: Optional[str] = None, **kwargs ): @@ -3651,9 +3553,9 @@ def __init__( :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The ARM resource tags. + :keyword tags: The ARM resource tags. :paramtype tags: dict[str, str] - :keyword status: The current status of task. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of task. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskStatus :keyword platform: The platform properties against which the run has to happen. :paramtype platform: @@ -3678,7 +3580,7 @@ def __init__( log artifact. :paramtype log_template: str """ - super(TaskUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.status = status @@ -3692,54 +3594,49 @@ def __init__( self.log_template = log_template -class TimerTrigger(msrest.serialization.Model): +class TimerTrigger(_serialization.Model): """The properties of a timer trigger. All required parameters must be populated in order to send to Azure. - :ivar schedule: Required. The CRON expression for the task schedule. + :ivar schedule: The CRON expression for the task schedule. Required. :vartype schedule: str - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'schedule': {'required': True}, - 'name': {'required': True}, + "schedule": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "schedule": {"key": "schedule", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - schedule: str, - name: str, - status: Optional[Union[str, "TriggerStatus"]] = None, - **kwargs + self, *, schedule: str, name: str, status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ - :keyword schedule: Required. The CRON expression for the task schedule. + :keyword schedule: The CRON expression for the task schedule. Required. :paramtype schedule: str - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(TimerTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.status = status self.name = name -class TimerTriggerDescriptor(msrest.serialization.Model): +class TimerTriggerDescriptor(_serialization.Model): """TimerTriggerDescriptor. :ivar timer_trigger_name: The timer trigger name that caused the run. @@ -3749,16 +3646,12 @@ class TimerTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timer_trigger_name': {'key': 'timerTriggerName', 'type': 'str'}, - 'schedule_occurrence': {'key': 'scheduleOccurrence', 'type': 'str'}, + "timer_trigger_name": {"key": "timerTriggerName", "type": "str"}, + "schedule_occurrence": {"key": "scheduleOccurrence", "type": "str"}, } def __init__( - self, - *, - timer_trigger_name: Optional[str] = None, - schedule_occurrence: Optional[str] = None, - **kwargs + self, *, timer_trigger_name: Optional[str] = None, schedule_occurrence: Optional[str] = None, **kwargs ): """ :keyword timer_trigger_name: The timer trigger name that caused the run. @@ -3766,32 +3659,32 @@ def __init__( :keyword schedule_occurrence: The occurrence that triggered the run. :paramtype schedule_occurrence: str """ - super(TimerTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_trigger_name = timer_trigger_name self.schedule_occurrence = schedule_occurrence -class TimerTriggerUpdateParameters(msrest.serialization.Model): +class TimerTriggerUpdateParameters(_serialization.Model): """The properties for updating a timer trigger. All required parameters must be populated in order to send to Azure. :ivar schedule: The CRON expression for the task schedule. :vartype schedule: str - :ivar status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :ivar status: The current status of trigger. Known values are: "Disabled" and "Enabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :ivar name: Required. The name of the trigger. + :ivar name: The name of the trigger. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "schedule": {"key": "schedule", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -3799,25 +3692,25 @@ def __init__( *, name: str, schedule: Optional[str] = None, - status: Optional[Union[str, "TriggerStatus"]] = None, + status: Optional[Union[str, "_models.TriggerStatus"]] = None, **kwargs ): """ :keyword schedule: The CRON expression for the task schedule. :paramtype schedule: str - :keyword status: The current status of trigger. Possible values include: "Disabled", "Enabled". + :keyword status: The current status of trigger. Known values are: "Disabled" and "Enabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TriggerStatus - :keyword name: Required. The name of the trigger. + :keyword name: The name of the trigger. Required. :paramtype name: str """ - super(TimerTriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.status = status self.name = name -class TriggerProperties(msrest.serialization.Model): +class TriggerProperties(_serialization.Model): """The properties of a trigger. :ivar timer_triggers: The collection of timer triggers. @@ -3832,17 +3725,17 @@ class TriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'timer_triggers': {'key': 'timerTriggers', 'type': '[TimerTrigger]'}, - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTrigger]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTrigger'}, + "timer_triggers": {"key": "timerTriggers", "type": "[TimerTrigger]"}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTrigger]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTrigger"}, } def __init__( self, *, - timer_triggers: Optional[List["TimerTrigger"]] = None, - source_triggers: Optional[List["SourceTrigger"]] = None, - base_image_trigger: Optional["BaseImageTrigger"] = None, + timer_triggers: Optional[List["_models.TimerTrigger"]] = None, + source_triggers: Optional[List["_models.SourceTrigger"]] = None, + base_image_trigger: Optional["_models.BaseImageTrigger"] = None, **kwargs ): """ @@ -3856,13 +3749,13 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTrigger """ - super(TriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_triggers = timer_triggers self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger -class TriggerUpdateParameters(msrest.serialization.Model): +class TriggerUpdateParameters(_serialization.Model): """The properties for updating triggers. :ivar timer_triggers: The collection of timer triggers. @@ -3877,17 +3770,17 @@ class TriggerUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'timer_triggers': {'key': 'timerTriggers', 'type': '[TimerTriggerUpdateParameters]'}, - 'source_triggers': {'key': 'sourceTriggers', 'type': '[SourceTriggerUpdateParameters]'}, - 'base_image_trigger': {'key': 'baseImageTrigger', 'type': 'BaseImageTriggerUpdateParameters'}, + "timer_triggers": {"key": "timerTriggers", "type": "[TimerTriggerUpdateParameters]"}, + "source_triggers": {"key": "sourceTriggers", "type": "[SourceTriggerUpdateParameters]"}, + "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTriggerUpdateParameters"}, } def __init__( self, *, - timer_triggers: Optional[List["TimerTriggerUpdateParameters"]] = None, - source_triggers: Optional[List["SourceTriggerUpdateParameters"]] = None, - base_image_trigger: Optional["BaseImageTriggerUpdateParameters"] = None, + timer_triggers: Optional[List["_models.TimerTriggerUpdateParameters"]] = None, + source_triggers: Optional[List["_models.SourceTriggerUpdateParameters"]] = None, + base_image_trigger: Optional["_models.BaseImageTriggerUpdateParameters"] = None, **kwargs ): """ @@ -3901,13 +3794,13 @@ def __init__( :paramtype base_image_trigger: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.BaseImageTriggerUpdateParameters """ - super(TriggerUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.timer_triggers = timer_triggers self.source_triggers = source_triggers self.base_image_trigger = base_image_trigger -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -3917,23 +3810,17 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py index 50962a67c7b6..4e49224958c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py @@ -12,10 +12,16 @@ from ._task_runs_operations import TaskRunsOperations from ._tasks_operations import TasksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AgentPoolsOperations', - 'RegistriesOperations', - 'RunsOperations', - 'TaskRunsOperations', - 'TasksOperations', + "AgentPoolsOperations", + "RegistriesOperations", + "RunsOperations", + "TaskRunsOperations", + "TasksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_agent_pools_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_agent_pools_operations.py index 852cbff2164a..cc4ee5f97fd8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_agent_pools_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_agent_pools_operations.py @@ -6,339 +6,344 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, agent_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str', max_length=20, min_length=3, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "agentPoolName": _SERIALIZER.url( + "agent_pool_name", agent_pool_name, "str", max_length=20, min_length=3, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, agent_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str', max_length=20, min_length=3, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "agentPoolName": _SERIALIZER.url( + "agent_pool_name", agent_pool_name, "str", max_length=20, min_length=3, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, agent_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str', max_length=20, min_length=3, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "agentPoolName": _SERIALIZER.url( + "agent_pool_name", agent_pool_name, "str", max_length=20, min_length=3, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - agent_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, agent_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str', max_length=20, min_length=3, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "agentPoolName": _SERIALIZER.url( + "agent_pool_name", agent_pool_name, "str", max_length=20, min_length=3, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_queue_status_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, agent_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "agentPoolName": _SERIALIZER.url("agent_pool_name", agent_pool_name, 'str', max_length=20, min_length=3, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "agentPoolName": _SERIALIZER.url( + "agent_pool_name", agent_pool_name, "str", max_length=20, min_length=3, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AgentPoolsOperations(object): - """AgentPoolsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AgentPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`agent_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.AgentPool": + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.AgentPool: """Gets the detailed information for a given agent pool. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AgentPool, or the result of cls(response) + :return: AgentPool or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,72 +351,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, agent_pool_name: str, - agent_pool: "_models.AgentPool", + agent_pool: Union[_models.AgentPool, IO], **kwargs: Any - ) -> "_models.AgentPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] + ) -> _models.AgentPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(agent_pool, 'AgentPool') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(agent_pool, (IO, bytes)): + _content = agent_pool + else: + _json = self._serialize.body(agent_pool, "AgentPool") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + agent_pool: _models.AgentPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentPool]: + """Creates an agent pool for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param agent_pool: The parameters of an agent pool that needs to scheduled. Required. + :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool + :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 AgentPool or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + agent_pool: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentPool]: + """Creates an agent pool for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param agent_pool: The parameters of an agent pool that needs to scheduled. Required. + :type agent_pool: 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 AgentPool or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -419,20 +521,24 @@ def begin_create( resource_group_name: str, registry_name: str, agent_pool_name: str, - agent_pool: "_models.AgentPool", + agent_pool: Union[_models.AgentPool, IO], **kwargs: Any - ) -> LROPoller["_models.AgentPool"]: + ) -> LROPoller[_models.AgentPool]: """Creates an agent pool for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str - :param agent_pool: The parameters of an agent pool that needs to scheduled. - :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool + :param agent_pool: The parameters of an agent pool that needs to scheduled. Is either a model + type or a IO type. Required. + :type agent_pool: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool 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 @@ -444,17 +550,19 @@ def begin_create( :return: An instance of LROPoller that returns either AgentPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -463,93 +571,100 @@ def begin_create( agent_pool=agent_pool, 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 = pipeline_response.http_response - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified agent pool resource. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_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. @@ -561,102 +676,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, agent_pool_name: str, - update_parameters: "_models.AgentPoolUpdateParameters", + update_parameters: Union[_models.AgentPoolUpdateParameters, IO], **kwargs: Any - ) -> "_models.AgentPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] + ) -> _models.AgentPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(update_parameters, 'AgentPoolUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "AgentPoolUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + update_parameters: _models.AgentPoolUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentPool]: + """Updates an agent pool with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param update_parameters: The parameters for updating an agent pool. Required. + :type update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters + :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 AgentPool or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + agent_pool_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentPool]: + """Updates an agent pool with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param agent_pool_name: The name of the agent pool. Required. + :type agent_pool_name: str + :param update_parameters: The parameters for updating an agent pool. Required. + :type update_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 AgentPool or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -664,21 +884,25 @@ def begin_update( resource_group_name: str, registry_name: str, agent_pool_name: str, - update_parameters: "_models.AgentPoolUpdateParameters", + update_parameters: Union[_models.AgentPoolUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.AgentPool"]: + ) -> LROPoller[_models.AgentPool]: """Updates an agent pool with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str - :param update_parameters: The parameters for updating an agent pool. + :param update_parameters: The parameters for updating an agent pool. Is either a model type or + a IO type. Required. :type update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolUpdateParameters 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 @@ -690,17 +914,19 @@ def begin_update( :return: An instance of LROPoller that returns either AgentPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentPool] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -709,81 +935,96 @@ def begin_update( update_parameters=update_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 = pipeline_response.http_response - deserialized = self._deserialize('AgentPool', pipeline_response) + deserialized = self._deserialize("AgentPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.AgentPoolListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.AgentPool"]: """Lists all the agent pools for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AgentPoolListResult or the result of cls(response) + :return: An iterator like instance of either AgentPool or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPoolListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -794,16 +1035,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AgentPoolListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -814,59 +1053,63 @@ 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.ContainerRegistry/registries/{registryName}/agentPools"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools" + } @distributed_trace def get_queue_status( - self, - resource_group_name: str, - registry_name: str, - agent_pool_name: str, - **kwargs: Any - ) -> "_models.AgentPoolQueueStatus": + self, resource_group_name: str, registry_name: str, agent_pool_name: str, **kwargs: Any + ) -> _models.AgentPoolQueueStatus: """Gets the count of queued runs for a given agent pool. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param agent_pool_name: The name of the agent pool. + :param agent_pool_name: The name of the agent pool. Required. :type agent_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AgentPoolQueueStatus, or the result of cls(response) + :return: AgentPoolQueueStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.AgentPoolQueueStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentPoolQueueStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.AgentPoolQueueStatus] = kwargs.pop("cls", None) - request = build_get_queue_status_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, agent_pool_name=agent_pool_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_queue_status.metadata['url'], + template_url=self.get_queue_status.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -874,12 +1117,13 @@ def get_queue_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AgentPoolQueueStatus', pipeline_response) + deserialized = self._deserialize("AgentPoolQueueStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_queue_status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus"} # type: ignore - + get_queue_status.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py index c1a44c0f6705..6ab0d00eceb7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py @@ -6,199 +6,289 @@ # 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, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_schedule_run_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_schedule_run_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_build_source_upload_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: "_models.RunRequest", - **kwargs: Any - ) -> Optional["_models.Run"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Run"]] + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> Optional[_models.Run]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(run_request, 'RunRequest') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_schedule_run_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Run]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_request, (IO, bytes)): + _content = run_request + else: + _json = self._serialize.body(run_request, "RunRequest") + + request = build_schedule_run_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._schedule_run_initial.metadata['url'], + content=_content, + template_url=self._schedule_run_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _schedule_run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore - + _schedule_run_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } - @distributed_trace + @overload def begin_schedule_run( self, resource_group_name: str, registry_name: str, - run_request: "_models.RunRequest", + run_request: _models.RunRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Schedules a new run based on the request parameters and add it to the run queue. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_request: The parameters of a run that needs to scheduled. + :param run_request: The parameters of a run that needs to scheduled. Required. :type run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest + :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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_schedule_run( + self, + resource_group_name: str, + registry_name: str, + run_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Required. + :type run_request: 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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_schedule_run( + self, resource_group_name: str, registry_name: str, run_request: Union[_models.RunRequest, IO], **kwargs: Any + ) -> LROPoller[_models.Run]: + """Schedules a new run based on the request parameters and add it to the run queue. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_request: The parameters of a run that needs to scheduled. Is either a model type or + a IO type. Required. + :type run_request: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunRequest 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 @@ -210,17 +300,19 @@ def begin_schedule_run( :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._schedule_run_initial( resource_group_name=resource_group_name, @@ -228,76 +320,86 @@ def begin_schedule_run( run_request=run_request, 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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_schedule_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun"} # type: ignore + begin_schedule_run.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + } @distributed_trace def get_build_source_upload_url( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.SourceUploadDefinition": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.SourceUploadDefinition: """Get the upload location for the user to be able to upload the source. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceUploadDefinition, or the result of cls(response) + :return: SourceUploadDefinition or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.SourceUploadDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceUploadDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - request = build_get_build_source_upload_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_build_source_upload_url.metadata['url'], + template_url=self.get_build_source_upload_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -305,12 +407,13 @@ def get_build_source_upload_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceUploadDefinition', pipeline_response) + deserialized = self._deserialize("SourceUploadDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_build_source_upload_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl"} # type: ignore - + get_build_source_upload_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_runs_operations.py index 9026596f9005..8c9eebfef5f2 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_runs_operations.py @@ -6,252 +6,253 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, registry_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_log_sas_url_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + +def build_cancel_request( + resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "runId": _SERIALIZER.url("run_id", run_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "runId": _SERIALIZER.url("run_id", run_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RunsOperations(object): - """RunsOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -261,13 +262,13 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.RunListResult"]: + ) -> Iterable["_models.Run"]: """Gets all the runs for a registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except 'Not', @@ -277,43 +278,56 @@ def list( return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RunListResult or the result of cls(response) + :return: An iterator like instance of either Run or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -324,16 +338,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -344,59 +356,61 @@ 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.ContainerRegistry/registries/{registryName}/runs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.Run": + def get(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> _models.Run: """Gets the detailed information for a given run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Run, or the result of cls(response) + :return: Run or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,72 +418,170 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } def _update_initial( self, resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> "_models.Run": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] + ) -> _models.Run: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(run_update_parameters, 'RunUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_update_parameters, (IO, bytes)): + _content = run_update_parameters + else: + _json = self._serialize.body(run_update_parameters, "RunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: _models.RunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters + :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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + run_id: str, + run_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Run]: + """Patch the run properties. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param run_id: The run ID. Required. + :type run_id: str + :param run_update_parameters: The run update properties. Required. + :type run_update_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 Run or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -477,21 +589,25 @@ def begin_update( resource_group_name: str, registry_name: str, run_id: str, - run_update_parameters: "_models.RunUpdateParameters", + run_update_parameters: Union[_models.RunUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Run"]: + ) -> LROPoller[_models.Run]: """Patch the run properties. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str - :param run_update_parameters: The run update properties. + :param run_update_parameters: The run update properties. Is either a model type or a IO type. + Required. :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunUpdateParameters 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 @@ -503,17 +619,19 @@ def begin_update( :return: An instance of LROPoller that returns either Run or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Run] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Run"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Run] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -522,80 +640,89 @@ def begin_update( run_update_parameters=run_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Run', pipeline_response) + deserialized = self._deserialize("Run", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + } @distributed_trace def get_log_sas_url( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> "_models.RunGetLogResult": + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any + ) -> _models.RunGetLogResult: """Gets a link to download the run logs. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RunGetLogResult, or the result of cls(response) + :return: RunGetLogResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.RunGetLogResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunGetLogResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - request = build_get_log_sas_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_sas_url.metadata['url'], + template_url=self.get_log_sas_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,76 +730,77 @@ def get_log_sas_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RunGetLogResult', pipeline_response) + deserialized = self._deserialize("RunGetLogResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_log_sas_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl"} # type: ignore - + get_log_sas_url.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + } def _cancel_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_cancel_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_cancel_request( resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._cancel_initial.metadata['url'], + template_url=self._cancel_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore - + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } @distributed_trace - def begin_cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - run_id: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_cancel(self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any) -> LROPoller[None]: """Cancel an existing run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param run_id: The run ID. + :param run_id: The run ID. Required. :type run_id: 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. @@ -684,42 +812,50 @@ def begin_cancel( # 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, run_id=run_id, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel"} # type: ignore + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_task_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_task_runs_operations.py index a7f132d0e50f..da7f671bb8a2 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_task_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_task_runs_operations.py @@ -6,339 +6,342 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskRunName": _SERIALIZER.url("task_run_name", task_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskRunName": _SERIALIZER.url( + "task_run_name", task_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, task_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskRunName": _SERIALIZER.url("task_run_name", task_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskRunName": _SERIALIZER.url( + "task_run_name", task_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, task_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskRunName": _SERIALIZER.url("task_run_name", task_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskRunName": _SERIALIZER.url( + "task_run_name", task_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - task_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, task_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskRunName": _SERIALIZER.url("task_run_name", task_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskRunName": _SERIALIZER.url( + "task_run_name", task_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_details_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskRunName": _SERIALIZER.url("task_run_name", task_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskRunName": _SERIALIZER.url( + "task_run_name", task_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TaskRunsOperations(object): - """TaskRunsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TaskRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`task_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any - ) -> "_models.TaskRun": + def get(self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any) -> _models.TaskRun: """Gets the detailed information for a given task run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TaskRun, or the result of cls(response) + :return: TaskRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,72 +349,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, task_run_name: str, - task_run: "_models.TaskRun", + task_run: Union[_models.TaskRun, IO], **kwargs: Any - ) -> "_models.TaskRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] + ) -> _models.TaskRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_run, 'TaskRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_run, (IO, bytes)): + _content = task_run + else: + _json = self._serialize.body(task_run, "TaskRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + task_run: _models.TaskRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TaskRun]: + """Creates a task run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param task_run: The parameters of a run that needs to scheduled. Required. + :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun + :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 TaskRun or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + task_run: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TaskRun]: + """Creates a task run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param task_run: The parameters of a run that needs to scheduled. Required. + :type task_run: 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 TaskRun or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -419,20 +519,24 @@ def begin_create( resource_group_name: str, registry_name: str, task_run_name: str, - task_run: "_models.TaskRun", + task_run: Union[_models.TaskRun, IO], **kwargs: Any - ) -> LROPoller["_models.TaskRun"]: + ) -> LROPoller[_models.TaskRun]: """Creates a task run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str - :param task_run: The parameters of a run that needs to scheduled. - :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun + :param task_run: The parameters of a run that needs to scheduled. Is either a model type or a + IO type. Required. + :type task_run: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun 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 @@ -444,17 +548,19 @@ def begin_create( :return: An instance of LROPoller that returns either TaskRun or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -463,93 +569,100 @@ def begin_create( task_run=task_run, 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 = pipeline_response.http_response - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified task run resource. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_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. @@ -561,102 +674,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, task_run_name: str, - update_parameters: "_models.TaskRunUpdateParameters", + update_parameters: Union[_models.TaskRunUpdateParameters, IO], **kwargs: Any - ) -> "_models.TaskRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] + ) -> _models.TaskRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(update_parameters, 'TaskRunUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "TaskRunUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + update_parameters: _models.TaskRunUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TaskRun]: + """Updates a task run with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param update_parameters: The parameters for updating a task run. Required. + :type update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters + :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 TaskRun or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_run_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TaskRun]: + """Updates a task run with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_run_name: The name of the task run. Required. + :type task_run_name: str + :param update_parameters: The parameters for updating a task run. Required. + :type update_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 TaskRun or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -664,21 +882,25 @@ def begin_update( resource_group_name: str, registry_name: str, task_run_name: str, - update_parameters: "_models.TaskRunUpdateParameters", + update_parameters: Union[_models.TaskRunUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.TaskRun"]: + ) -> LROPoller[_models.TaskRun]: """Updates a task run with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str - :param update_parameters: The parameters for updating a task run. + :param update_parameters: The parameters for updating a task run. Is either a model type or a + IO type. Required. :type update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunUpdateParameters 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 @@ -690,17 +912,19 @@ def begin_update( :return: An instance of LROPoller that returns either TaskRun or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -709,80 +933,89 @@ def begin_update( update_parameters=update_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 = pipeline_response.http_response - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + } @distributed_trace def get_details( - self, - resource_group_name: str, - registry_name: str, - task_run_name: str, - **kwargs: Any - ) -> "_models.TaskRun": + self, resource_group_name: str, registry_name: str, task_run_name: str, **kwargs: Any + ) -> _models.TaskRun: """Gets the detailed information for a given task run that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_run_name: The name of the task run. + :param task_run_name: The name of the task run. Required. :type task_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TaskRun, or the result of cls(response) + :return: TaskRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRun] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_run_name=task_run_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -790,64 +1023,75 @@ def get_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TaskRun', pipeline_response) + deserialized = self._deserialize("TaskRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TaskRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.TaskRun"]: """Lists all the task runs for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskRunListResult or the result of cls(response) + :return: An iterator like instance of either TaskRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -858,16 +1102,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TaskRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -878,8 +1120,8 @@ 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.ContainerRegistry/registries/{registryName}/taskRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tasks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tasks_operations.py index c37ea1935e09..8be9c9c97593 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tasks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tasks_operations.py @@ -6,340 +6,351 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - task_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_get_details_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, task_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "taskName": _SERIALIZER.url("task_name", task_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class TasksOperations(object): - """TasksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TasksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`tasks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TaskListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Task"]: """Lists all the tasks for a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TaskListResult or the result of cls(response) + :return: An iterator like instance of either Task or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TaskListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -350,16 +361,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TaskListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -370,59 +379,61 @@ 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.ContainerRegistry/registries/{registryName}/tasks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Get the properties of a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,72 +441,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_create_parameters, 'Task') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_create_parameters, (IO, bytes)): + _content = task_create_parameters + else: + _json = self._serialize.body(task_create_parameters, "Task") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: _models.Task, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Creates a task for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_create_parameters: The parameters for creating a task. Required. + :type task_create_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -503,20 +611,25 @@ def begin_create( resource_group_name: str, registry_name: str, task_name: str, - task_create_parameters: "_models.Task", + task_create_parameters: Union[_models.Task, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Creates a task for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_create_parameters: The parameters for creating a task. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task + :param task_create_parameters: The parameters for creating a task. Is either a model type or a + IO type. Required. + :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task 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 @@ -528,17 +641,19 @@ def begin_create( :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -547,93 +662,100 @@ def begin_create( task_create_parameters=task_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a specified task. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_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. @@ -645,102 +767,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> "_models.Task": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] + ) -> _models.Task: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(task_update_parameters, 'TaskUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(task_update_parameters, (IO, bytes)): + _content = task_update_parameters + else: + _json = self._serialize.body(task_update_parameters, "TaskUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: _models.TaskUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters + :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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + task_name: str, + task_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Task]: + """Updates a task with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param task_name: The name of the container registry task. Required. + :type task_name: str + :param task_update_parameters: The parameters for updating a task. Required. + :type task_update_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 Task or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -748,21 +975,25 @@ def begin_update( resource_group_name: str, registry_name: str, task_name: str, - task_update_parameters: "_models.TaskUpdateParameters", + task_update_parameters: Union[_models.TaskUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Task"]: + ) -> LROPoller[_models.Task]: """Updates a task with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str - :param task_update_parameters: The parameters for updating a task. + :param task_update_parameters: The parameters for updating a task. Is either a model type or a + IO type. Required. :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TaskUpdateParameters 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 @@ -774,17 +1005,19 @@ def begin_update( :return: An instance of LROPoller that returns either Task or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -793,80 +1026,87 @@ def begin_update( task_update_parameters=task_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + } @distributed_trace - def get_details( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - **kwargs: Any - ) -> "_models.Task": + def get_details(self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any) -> _models.Task: """Returns a task with extended information that includes all secrets. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param task_name: The name of the container registry task. + :param task_name: The name of the container registry task. Required. :type task_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Task, or the result of cls(response) + :return: Task or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Task - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Task"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-06-01-preview") + ) + cls: ClsType[_models.Task] = kwargs.pop("cls", None) - request = build_get_details_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, task_name=task_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_details.metadata['url'], + template_url=self.get_details.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -874,12 +1114,13 @@ def get_details( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Task', pipeline_response) + deserialized = self._deserialize("Task", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_details.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails"} # type: ignore - + get_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_configuration.py index 82480dc97390..0058756f18f9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-12-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop("api_version", "2019-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_container_registry_management_client.py index 7f212fc09ad2..f7e678070d0c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_container_registry_management_client.py @@ -9,20 +9,29 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, WebhooksOperations +from .operations import ( + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar export_pipelines: ExportPipelinesOperations operations @@ -48,9 +57,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2019_12_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -68,28 +77,31 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -98,7 +110,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 @@ -111,15 +123,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_metadata.json index 2ae35a1a8aba..fd67b2676ee4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -106,4 +106,4 @@ "replications": "ReplicationsOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_configuration.py index df5b55464b3d..3ea421038273 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-12-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop("api_version", "2019-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_container_registry_management_client.py index 45371eac3c1b..96707fbd998d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,29 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, WebhooksOperations +from .operations import ( + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar export_pipelines: ExportPipelinesOperations operations @@ -48,9 +57,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -68,28 +77,31 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -98,7 +110,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/__init__.py index a6ae2335e9f2..0b30fbc6b611 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'WebhooksOperations', + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_export_pipelines_operations.py index 7ed6ad110d01..912c8e3651cd 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_import_pipelines_operations.py index 1fa3e92d4c4f..029b9954fae0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_operations.py index 960abfacee8f..f95a93a5ed6d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_pipeline_runs_operations.py index 692c6d433597..9bddfcbbf7e3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +294,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun 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 @@ -200,17 +325,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +346,74 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +423,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -317,95 +450,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +566,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +583,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_private_endpoint_connections_operations.py index 31d3fea83e90..7ac15632505d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2019_12_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +298,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2019_12_01_preview.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 :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 @@ -201,17 +330,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -220,65 +351,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -288,25 +428,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -318,95 +455,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -417,16 +574,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -436,8 +591,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_registries_operations.py index 9ad81e343b1a..4d744b0c64bf 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') - - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +133,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters 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 @@ -123,202 +242,287 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -326,36 +530,111 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry 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 @@ -368,17 +647,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -386,63 +667,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -452,22 +743,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -479,80 +766,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -560,37 +871,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters 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 @@ -603,17 +994,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -621,76 +1014,93 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -701,16 +1111,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -720,49 +1128,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -773,16 +1195,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,247 +1212,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1043,16 +1563,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1062,8 +1580,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_replications_operations.py index d3b9fdc38333..2cbc5e7400bc 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_replications_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +294,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication 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 @@ -199,17 +324,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -218,65 +345,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,25 +422,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -316,83 +449,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -400,18 +557,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -419,21 +658,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters 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 @@ -446,17 +689,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -465,82 +710,96 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +810,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +827,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_webhooks_operations.py index 7fbe741d630e..b3458175a0f1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_webhooks_operations.py @@ -6,147 +6,190 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +197,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +298,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters 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 @@ -200,17 +329,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +350,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +427,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -317,83 +454,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +562,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +663,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters 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 @@ -447,17 +694,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +715,96 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +815,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,191 +832,211 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -765,16 +1047,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -784,8 +1064,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/__init__.py index 103eeff5f15a..49f88b30abda 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/__init__.py @@ -83,135 +83,137 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ImportMode, - LastModifiedByType, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Actor', - 'CallbackConfig', - 'EncryptionProperty', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'KeyVaultProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'Sku', - 'Source', - 'Status', - 'SystemData', - 'Target', - 'TrustPolicy', - 'UserIdentityProperties', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ImportMode', - 'LastModifiedByType', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', + "Actor", + "CallbackConfig", + "EncryptionProperty", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "KeyVaultProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "Sku", + "Source", + "Status", + "SystemData", + "Target", + "TrustPolicy", + "UserIdentityProperties", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ImportMode", + "LastModifiedByType", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_container_registry_management_client_enums.py index 6096c5ae7df0..e92f11bf1a3a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_container_registry_management_client_enums.py @@ -7,56 +7,55 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -64,64 +63,66 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the pipeline at the time the operation was called. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the pipeline at the time the operation was called.""" CREATING = "Creating" UPDATING = "Updating" @@ -130,61 +131,63 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -192,9 +195,9 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_models_py3.py index 37d62cc3c820..6a7f81bd5fa4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/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. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -23,67 +26,56 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -92,32 +84,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -125,20 +117,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -156,17 +143,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -179,12 +166,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -206,25 +193,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -245,7 +232,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -255,7 +242,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -266,17 +253,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -284,12 +265,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -305,17 +286,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -334,7 +315,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -342,7 +323,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -358,11 +339,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -387,7 +368,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -395,7 +376,7 @@ def __init__( self.version = version -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -411,26 +392,22 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -461,39 +438,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -509,7 +486,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -517,7 +494,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -528,16 +505,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -546,12 +519,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -562,29 +535,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -592,25 +558,25 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -623,10 +589,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -634,8 +600,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -643,8 +609,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -655,19 +621,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2019_12_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -676,33 +642,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -711,11 +677,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -749,41 +715,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -802,7 +768,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -811,7 +777,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -822,16 +788,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -840,67 +802,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -912,22 +872,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -936,7 +896,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -947,98 +907,86 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1057,33 +1005,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1091,13 +1033,13 @@ def __init__( self.last_key_rotation_timestamp = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. @@ -1108,26 +1050,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -1136,13 +1078,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1158,10 +1100,13 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1169,8 +1114,8 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1185,14 +1130,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1206,10 +1151,10 @@ class OperationDisplayDefinition(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__( @@ -1231,14 +1176,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1251,16 +1196,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1271,12 +1212,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1288,9 +1229,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1309,13 +1250,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1333,12 +1274,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1366,7 +1307,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1375,7 +1316,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1387,15 +1328,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -1406,7 +1347,7 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications @@ -1424,8 +1365,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -1438,29 +1379,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -1471,14 +1412,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -1489,16 +1430,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -1507,12 +1444,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -1533,11 +1470,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -1545,8 +1482,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -1567,7 +1504,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -1575,7 +1512,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -1605,16 +1542,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -1622,13 +1559,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -1659,7 +1596,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -1672,11 +1609,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -1684,35 +1620,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -1720,31 +1654,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -1752,58 +1685,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -1812,25 +1735,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -1839,25 +1757,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -1871,17 +1784,17 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -1894,13 +1807,13 @@ def __init__( :paramtype retention_policy: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RetentionPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -1908,21 +1821,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1946,35 +1854,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -1986,13 +1897,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2019_12_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2005,14 +1916,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2025,12 +1936,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2050,22 +1961,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2084,7 +1995,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2093,7 +2004,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2105,16 +2016,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2125,61 +2032,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2187,84 +2094,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2277,47 +2169,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2326,7 +2212,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2339,14 +2225,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.IdentityProperties @@ -2355,8 +2241,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -2381,77 +2267,80 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.NetworkRuleBypassOptions """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -2469,15 +2358,15 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.NetworkRuleBypassOptions """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -2495,7 +2384,7 @@ def __init__( self.network_rule_bypass_options = network_rule_bypass_options -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -2506,16 +2395,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -2524,12 +2409,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -2540,17 +2425,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -2558,53 +2437,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -2617,9 +2491,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -2639,50 +2513,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Sku @@ -2699,48 +2569,48 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.NetworkRuleBypassOptions """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, **kwargs ): """ :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Sku @@ -2757,15 +2627,15 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.NetworkRuleBypassOptions """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -2778,25 +2648,25 @@ def __init__( self.network_rule_bypass_options = network_rule_bypass_options -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -2805,28 +2675,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -2834,20 +2704,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -2864,15 +2729,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState @@ -2885,53 +2750,48 @@ class Replication(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - **kwargs + self, *, location: str, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: bool = True, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -2942,16 +2802,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -2960,15 +2816,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -2977,31 +2833,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3019,17 +2871,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3050,7 +2902,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3058,7 +2910,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3067,83 +2919,72 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -3154,17 +2995,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -3172,12 +3007,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -3191,44 +3026,40 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -3236,44 +3067,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -3282,17 +3113,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -3306,15 +3137,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -3335,12 +3166,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -3352,7 +3183,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -3364,44 +3195,42 @@ def __init__( self.version = version -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -3411,64 +3240,56 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -3486,15 +3307,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -3504,32 +3325,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -3537,19 +3358,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -3560,29 +3381,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -3594,17 +3415,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -3614,23 +3435,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -3641,7 +3462,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -3651,7 +3472,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -3662,17 +3483,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -3680,22 +3495,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -3707,12 +3522,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -3721,20 +3536,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -3745,7 +3560,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/__init__.py index a6ae2335e9f2..0b30fbc6b611 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/__init__.py @@ -15,13 +15,19 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'WebhooksOperations', + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_export_pipelines_operations.py index f9cd118d4e5e..8cae379aad53 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_export_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_import_pipelines_operations.py index 7175258e1399..8accb1d730b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_import_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_operations.py index 638d0629c8cd..865abbd1d7f3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - accept = "application/json" +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: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_pipeline_runs_operations.py index 041c30a0bc7f..b43d788c7875 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_pipeline_runs_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +336,100 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -328,21 +437,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun 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 @@ -355,17 +468,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +489,74 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +566,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -472,95 +593,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +709,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +726,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_private_endpoint_connections_operations.py index 4a16f4c27117..e4f83720d461 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,302 +6,341 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +348,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2019_12_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -328,22 +453,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2019_12_01_preview.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 :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 @@ -356,17 +485,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -375,65 +506,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -443,25 +583,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -473,95 +610,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -572,16 +729,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -591,8 +746,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_registries_operations.py index def701f90ffb..f9e9abefa3a9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_registries_operations.py @@ -6,539 +6,518 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -548,28 +527,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters 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 @@ -580,202 +636,287 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -783,36 +924,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry 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 @@ -824,17 +1038,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -842,63 +1058,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -908,22 +1134,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -935,80 +1157,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1016,37 +1262,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters 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 @@ -1058,17 +1382,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1076,76 +1402,93 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1156,16 +1499,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1175,49 +1516,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1228,16 +1583,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1247,247 +1600,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-12-01-preview") # type: str + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1498,16 +1951,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1517,8 +1968,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_replications_operations.py index f23c6456d4a7..95ed707dcf03 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_replications_operations.py @@ -6,348 +6,370 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +377,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +477,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication 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 @@ -400,17 +507,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +528,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +605,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -517,83 +632,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +740,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +841,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters 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 @@ -647,17 +872,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -666,82 +893,96 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -752,16 +993,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -771,8 +1010,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_webhooks_operations.py index 8ee79b4acbda..705e07ded389 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_webhooks_operations.py @@ -6,462 +6,482 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2019_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2019_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -469,18 +489,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -488,21 +588,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters 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 @@ -514,17 +618,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -533,65 +639,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -601,25 +716,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -631,83 +743,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -715,18 +851,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -734,21 +950,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters 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 @@ -760,17 +980,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -779,81 +1001,96 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -864,16 +1101,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -883,191 +1118,209 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2019_12_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-12-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1078,16 +1331,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1097,8 +1348,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_configuration.py index 0861045558f8..0153cc2bc426 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-11-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop("api_version", "2020-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_container_registry_management_client.py index 15a8a2869855..7159d40dcf38 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -56,9 +68,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2020_11_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,31 +88,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -109,7 +126,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 @@ -122,15 +139,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_metadata.json index 2050f8536077..4a90fb22a11b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "tokens": "TokensOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_configuration.py index 216605c85448..105539c94656 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-11-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop("api_version", "2020-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_container_registry_management_client.py index db8df9642685..17bbed33e3fe 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -57,9 +69,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2020_11_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -77,31 +89,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -110,7 +127,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_connected_registries_operations.py index 2dfc6e814887..b6b7455b2593 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_connected_registries_operations.py @@ -6,94 +6,118 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._connected_registries_operations import build_create_request_initial, build_deactivate_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConnectedRegistriesOperations: - """ConnectedRegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,72 +125,174 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -174,21 +300,25 @@ async def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry 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 @@ -201,17 +331,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -220,93 +352,100 @@ async def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -318,102 +457,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -421,21 +669,26 @@ async def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -448,17 +701,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -467,47 +722,48 @@ async def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -515,42 +771,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -561,16 +830,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -581,72 +848,74 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } async def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace_async - async def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -658,42 +927,50 @@ async def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deactivate_initial( + raw_result = await self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_export_pipelines_operations.py index d31990b769e9..4ab8b57c9b41 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_import_pipelines_operations.py index e06f761f39e5..aa46d0ce5f98 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_operations.py index d3f3cf330da6..18eafa733b73 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_pipeline_runs_operations.py index dec687a36700..db221046c724 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +294,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun 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 @@ -200,17 +325,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +346,74 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +423,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -317,95 +450,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +566,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +583,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_private_endpoint_connections_operations.py index 51dc6c7074a3..5a9e47a0cbd2 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2020_11_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +298,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2020_11_01_preview.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 :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 @@ -201,17 +330,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -220,65 +351,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -288,25 +428,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -318,95 +455,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -417,16 +574,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -436,8 +591,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_registries_operations.py index 91e800c73193..9c2c0cc6b0d6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_generate_credentials_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +134,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters 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 @@ -123,202 +243,287 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -326,36 +531,79 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 @@ -368,17 +616,51 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -386,63 +668,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -452,22 +744,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -479,80 +767,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -560,37 +872,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters 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 @@ -603,17 +995,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -621,76 +1015,93 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -701,16 +1112,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -720,49 +1129,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -773,16 +1196,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,247 +1213,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1043,16 +1564,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1062,47 +1581,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1111,34 +1646,114 @@ async def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters 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 @@ -1151,17 +1766,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1169,29 +1786,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_replications_operations.py index dee30154e7f3..9d4816f51077 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_replications_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +294,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication 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 @@ -199,17 +324,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -218,65 +345,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,25 +422,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -316,83 +449,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -400,18 +557,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -419,21 +658,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters 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 @@ -446,17 +689,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -465,82 +710,96 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +810,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +827,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_scope_maps_operations.py index d001ae05be7b..36ce6329bf87 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_scope_maps_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +295,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap 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 @@ -200,17 +326,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +347,74 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +424,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -317,83 +451,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +559,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +660,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters 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 @@ -447,17 +691,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +712,96 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +812,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +829,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_tokens_operations.py index 9f909110909f..f66655cf47b3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_tokens_operations.py @@ -6,147 +6,185 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +192,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +290,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token + 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 @@ -198,17 +320,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -217,65 +341,74 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -285,25 +418,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -315,83 +445,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -399,18 +553,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -418,21 +652,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters 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 @@ -444,17 +682,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -463,81 +703,96 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -548,16 +803,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -567,8 +820,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_webhooks_operations.py index 89f50bd1c03f..a1782945b113 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/aio/operations/_webhooks_operations.py @@ -6,147 +6,190 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +197,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +298,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters 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 @@ -200,17 +329,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +350,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +427,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -317,83 +454,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +562,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +663,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters 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 @@ -447,17 +694,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +715,96 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +815,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,191 +832,211 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -765,16 +1047,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -784,8 +1064,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/__init__.py index e584b3f8515c..a3590d350138 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/__init__.py @@ -110,184 +110,186 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActivationProperties', - 'ActiveDirectoryObject', - 'Actor', - 'CallbackConfig', - 'ConnectedRegistry', - 'ConnectedRegistryListResult', - 'ConnectedRegistryUpdateParameters', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'LoggingProperties', - 'LoginServerProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'ParentProperties', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'Sku', - 'Source', - 'Status', - 'StatusDetailProperties', - 'SyncProperties', - 'SyncUpdateProperties', - 'SystemData', - 'Target', - 'TlsCertificateProperties', - 'TlsProperties', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'TrustPolicy', - 'UserIdentityProperties', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ActivationStatus', - 'AuditLogStatus', - 'CertificateType', - 'ConnectedRegistryMode', - 'ConnectionState', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ImportMode', - 'LastModifiedByType', - 'LogLevel', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TlsStatus', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "Source", + "Status", + "StatusDetailProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_container_registry_management_client_enums.py index fc442419f023..26053df867c5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_container_registry_management_client_enums.py @@ -7,92 +7,91 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ActivationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The activation status of the connected registry. - """ + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" ACTIVE = "Active" INACTIVE = "Inactive" -class AuditLogStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether audit logs are enabled on the connected registry. - """ + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class CertificateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of certificate location. - """ + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" LOCAL_DIRECTORY = "LocalDirectory" -class ConnectedRegistryMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The mode of the connected registry resource that indicates the permissions of the registry. - """ + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" REGISTRY = "Registry" MIRROR = "Mirror" -class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current connection state of the connected registry. - """ + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" ONLINE = "Online" OFFLINE = "Offline" SYNCING = "Syncing" UNHEALTHY = "Unhealthy" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -100,18 +99,18 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity of logs persisted on the connected registry. - """ + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" DEBUG = "Debug" INFORMATION = "Information" @@ -119,55 +118,57 @@ class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" NONE = "None" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -176,87 +177,91 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TlsStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether HTTPS is enabled for the login server. - """ + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -264,16 +269,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_models_py3.py index 628956d2d28e..d922b982c7b5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/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. @@ -7,44 +8,41 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActivationProperties(msrest.serialization.Model): +class ActivationProperties(_serialization.Model): """The activation properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The activation status of the connected registry. Possible values include: - "Active", "Inactive". + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ActivationStatus """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ActivationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -56,17 +54,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -75,12 +67,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -89,63 +81,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -161,33 +142,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ConnectedRegistry(ProxyResource): +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes """An object that represents a connected registry for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -200,18 +177,18 @@ class ConnectedRegistry(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState :ivar mode: The mode of the connected registry resource that indicates the permissions of the - registry. Possible values include: "Registry", "Mirror". + registry. Known values are: "Registry" and "Mirror". :vartype mode: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryMode :ivar version: The current version of ACR runtime on the connected registry. :vartype version: str - :ivar connection_state: The current connection state of the connected registry. Possible values - include: "Online", "Offline", "Syncing", "Unhealthy". + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". :vartype connection_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectionState :ivar last_activity_time: The last activity time of the connected registry. @@ -235,49 +212,49 @@ class ConnectedRegistry(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'connection_state': {'readonly': True}, - 'last_activity_time': {'readonly': True}, - 'activation': {'readonly': True}, - 'status_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'connection_state': {'key': 'properties.connectionState', 'type': 'str'}, - 'last_activity_time': {'key': 'properties.lastActivityTime', 'type': 'iso-8601'}, - 'activation': {'key': 'properties.activation', 'type': 'ActivationProperties'}, - 'parent': {'key': 'properties.parent', 'type': 'ParentProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'LoginServerProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'status_details': {'key': 'properties.statusDetails', 'type': '[StatusDetailProperties]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, } def __init__( self, *, - mode: Optional[Union[str, "ConnectedRegistryMode"]] = None, - parent: Optional["ParentProperties"] = None, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, client_token_ids: Optional[List[str]] = None, - login_server: Optional["LoginServerProperties"] = None, - logging: Optional["LoggingProperties"] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, **kwargs ): """ :keyword mode: The mode of the connected registry resource that indicates the permissions of - the registry. Possible values include: "Registry", "Mirror". + the registry. Known values are: "Registry" and "Mirror". :paramtype mode: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryMode :keyword parent: The parent of the connected registry. @@ -291,7 +268,7 @@ def __init__( :keyword logging: The logging properties of the connected registry. :paramtype logging: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.LoggingProperties """ - super(ConnectedRegistry, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.mode = mode self.version = None @@ -305,7 +282,7 @@ def __init__( self.status_details = None -class ConnectedRegistryListResult(msrest.serialization.Model): +class ConnectedRegistryListResult(_serialization.Model): """The result of a request to list connected registries for a container registry. :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink @@ -317,16 +294,12 @@ class ConnectedRegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectedRegistry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ConnectedRegistry"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of connected registries. Since this list may be incomplete, the @@ -336,12 +309,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of connected registries. :paramtype next_link: str """ - super(ConnectedRegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConnectedRegistryUpdateParameters(msrest.serialization.Model): +class ConnectedRegistryUpdateParameters(_serialization.Model): """The parameters for updating a connected registry. :ivar sync_properties: The sync properties of the connected registry with its parent. @@ -355,16 +328,16 @@ class ConnectedRegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sync_properties': {'key': 'properties.syncProperties', 'type': 'SyncUpdateProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, } def __init__( self, *, - sync_properties: Optional["SyncUpdateProperties"] = None, - logging: Optional["LoggingProperties"] = None, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, client_token_ids: Optional[List[str]] = None, **kwargs ): @@ -378,17 +351,17 @@ def __init__( to the connected registry. :paramtype client_token_ids: list[str] """ - super(ConnectedRegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sync_properties = sync_properties self.logging = logging self.client_token_ids = client_token_ids -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -397,32 +370,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -430,31 +403,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -465,15 +433,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -482,13 +450,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -497,14 +465,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -512,20 +480,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -543,17 +506,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -566,12 +529,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -593,25 +556,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -632,7 +595,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -642,7 +605,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -653,17 +616,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -671,12 +628,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -692,17 +649,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -721,7 +678,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -729,7 +686,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -745,11 +702,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -774,7 +731,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -806,39 +763,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -854,7 +811,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -862,7 +819,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -873,16 +830,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -891,12 +844,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -907,29 +860,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -937,17 +883,17 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -956,15 +902,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -972,7 +918,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -982,17 +928,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -1003,16 +949,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1021,20 +963,20 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1047,10 +989,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1058,8 +1000,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1067,8 +1009,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1079,19 +1021,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2020_11_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1100,33 +1042,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1135,11 +1077,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -1173,41 +1115,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -1226,7 +1168,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -1235,7 +1177,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1246,16 +1188,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1264,67 +1202,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -1336,22 +1272,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -1360,7 +1296,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -1371,144 +1307,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1527,33 +1444,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1561,45 +1472,45 @@ def __init__( self.last_key_rotation_timestamp = None -class LoggingProperties(msrest.serialization.Model): +class LoggingProperties(_serialization.Model): """The logging properties of the connected registry. - :ivar log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". :vartype log_level: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.LogLevel :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :vartype audit_log_status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.AuditLogStatus """ _attribute_map = { - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'audit_log_status': {'key': 'auditLogStatus', 'type': 'str'}, + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, } def __init__( self, *, - log_level: Optional[Union[str, "LogLevel"]] = "Information", - audit_log_status: Optional[Union[str, "AuditLogStatus"]] = "Disabled", + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", **kwargs ): """ - :keyword log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". :paramtype log_level: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.LogLevel :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :paramtype audit_log_status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.AuditLogStatus """ - super(LoggingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_level = log_level self.audit_log_status = audit_log_status -class LoginServerProperties(msrest.serialization.Model): +class LoginServerProperties(_serialization.Model): """The login server properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1611,33 +1522,29 @@ class LoginServerProperties(msrest.serialization.Model): """ _validation = { - 'host': {'readonly': True}, - 'tls': {'readonly': True}, + "host": {"readonly": True}, + "tls": {"readonly": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'tls': {'key': 'tls', 'type': 'TlsProperties'}, + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LoginServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.host = None self.tls = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. @@ -1648,26 +1555,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -1676,13 +1583,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1698,10 +1605,13 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1709,8 +1619,8 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1725,14 +1635,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1746,10 +1656,10 @@ class OperationDisplayDefinition(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__( @@ -1771,14 +1681,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1791,16 +1701,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1811,12 +1717,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1828,9 +1734,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1849,13 +1755,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1873,12 +1779,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1906,7 +1812,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1915,7 +1821,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1927,15 +1833,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -1946,48 +1852,48 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class ParentProperties(msrest.serialization.Model): +class ParentProperties(_serialization.Model): """The properties of the connected registry parent. All required parameters must be populated in order to send to Azure. :ivar id: The resource ID of the parent to which the connected registry will be associated. :vartype id: str - :ivar sync_properties: Required. The sync properties of the connected registry with its parent. + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. :vartype sync_properties: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SyncProperties """ _validation = { - 'sync_properties': {'required': True}, + "sync_properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'sync_properties': {'key': 'syncProperties', 'type': 'SyncProperties'}, + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, } def __init__( self, *, - sync_properties: "SyncProperties", - id: Optional[str] = None, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: The resource ID of the parent to which the connected registry will be associated. :paramtype id: str - :keyword sync_properties: Required. The sync properties of the connected registry with its - parent. + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. :paramtype sync_properties: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SyncProperties """ - super(ParentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.sync_properties = sync_properties @@ -2005,8 +1911,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -2019,29 +1925,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -2052,14 +1958,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -2070,16 +1976,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -2088,12 +1990,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -2114,11 +2016,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -2126,8 +2028,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -2148,7 +2050,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -2156,7 +2058,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -2186,16 +2088,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -2203,13 +2105,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -2240,7 +2142,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -2253,11 +2155,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -2265,35 +2166,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -2301,31 +2200,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -2333,58 +2231,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -2393,25 +2281,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -2420,25 +2303,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -2452,17 +2330,17 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -2475,13 +2353,13 @@ def __init__( :paramtype retention_policy: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RetentionPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -2489,21 +2367,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -2527,35 +2400,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2567,13 +2443,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2020_11_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2586,14 +2462,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2606,12 +2482,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2631,22 +2507,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2665,7 +2541,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2674,7 +2550,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2686,16 +2562,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2706,61 +2578,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2768,84 +2640,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2858,47 +2715,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2907,7 +2758,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2920,14 +2771,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.IdentityProperties @@ -2936,8 +2787,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -2962,15 +2813,15 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ZoneRedundancy :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -2978,71 +2829,74 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, - anonymous_pull_enabled: Optional[bool] = False, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -3060,21 +2914,21 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ZoneRedundancy :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -3094,7 +2948,7 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -3105,16 +2959,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -3123,12 +2973,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -3139,17 +2989,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -3157,53 +3001,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -3216,9 +3055,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -3238,50 +3077,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Sku @@ -3298,11 +3133,11 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.NetworkRuleBypassOptions :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3310,32 +3145,32 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, anonymous_pull_enabled: Optional[bool] = None, **kwargs ): @@ -3343,7 +3178,7 @@ def __init__( :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Sku @@ -3360,17 +3195,17 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.NetworkRuleBypassOptions :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -3384,25 +3219,25 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -3411,28 +3246,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -3440,20 +3275,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3470,15 +3300,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState @@ -3489,32 +3319,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -3522,33 +3352,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3559,16 +3389,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3577,15 +3403,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -3594,31 +3420,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3636,17 +3458,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3667,7 +3489,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3675,7 +3497,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3684,36 +3506,30 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status @@ -3738,8 +3554,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -3749,34 +3565,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3785,7 +3595,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -3793,7 +3603,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -3804,17 +3614,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -3822,12 +3626,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -3839,17 +3643,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3858,53 +3656,48 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -3915,17 +3708,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -3933,12 +3720,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -3952,30 +3739,26 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StatusDetailProperties(msrest.serialization.Model): +class StatusDetailProperties(_serialization.Model): """The status detail properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3993,28 +3776,24 @@ class StatusDetailProperties(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'code': {'readonly': True}, - 'description': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'correlation_id': {'readonly': True}, + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StatusDetailProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.code = None self.description = None @@ -4022,15 +3801,15 @@ def __init__( self.correlation_id = None -class SyncProperties(msrest.serialization.Model): +class SyncProperties(_serialization.Model): """The sync properties of the connected registry with its parent. 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 token_id: Required. The resource ID of the ACR token used to authenticate the connected - registry to its parent during sync. + :ivar token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. :vartype token_id: str :ivar schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4038,8 +3817,9 @@ class SyncProperties(msrest.serialization.Model): :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :vartype sync_window: ~datetime.timedelta - :ivar message_ttl: Required. The period of time for which a message is available to sync before - it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :vartype message_ttl: ~datetime.timedelta :ivar last_sync_time: The last time a sync occurred between the connected registry and its parent. @@ -4050,19 +3830,19 @@ class SyncProperties(msrest.serialization.Model): """ _validation = { - 'token_id': {'required': True}, - 'message_ttl': {'required': True}, - 'last_sync_time': {'readonly': True}, - 'gateway_endpoint': {'readonly': True}, + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'gateway_endpoint': {'key': 'gatewayEndpoint', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, } def __init__( @@ -4075,8 +3855,8 @@ def __init__( **kwargs ): """ - :keyword token_id: Required. The resource ID of the ACR token used to authenticate the - connected registry to its parent during sync. + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. :paramtype token_id: str :keyword schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4084,12 +3864,12 @@ def __init__( :keyword sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype sync_window: ~datetime.timedelta - :keyword message_ttl: Required. The period of time for which a message is available to sync - before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per - ISO8601. + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.schedule = schedule self.sync_window = sync_window @@ -4098,7 +3878,7 @@ def __init__( self.gateway_endpoint = None -class SyncUpdateProperties(msrest.serialization.Model): +class SyncUpdateProperties(_serialization.Model): """The parameters for updating the sync properties of the connected registry with its parent. :ivar schedule: The cron expression indicating the schedule that the connected registry will @@ -4113,9 +3893,9 @@ class SyncUpdateProperties(msrest.serialization.Model): """ _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, } def __init__( @@ -4137,27 +3917,27 @@ def __init__( expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncUpdateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.sync_window = sync_window self.message_ttl = message_ttl -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -4165,44 +3945,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -4211,17 +3991,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -4235,15 +4015,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -4264,12 +4044,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -4281,7 +4061,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -4293,45 +4073,41 @@ def __init__( self.version = version -class TlsCertificateProperties(msrest.serialization.Model): +class TlsCertificateProperties(_serialization.Model): """The TLS certificate properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of certificate location. Possible values include: "LocalDirectory". + :ivar type: The type of certificate location. "LocalDirectory" :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.CertificateType :ivar location: Indicates the location of the certificates. :vartype location: str """ _validation = { - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsCertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.location = None -class TlsProperties(msrest.serialization.Model): +class TlsProperties(_serialization.Model): """The TLS properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Indicates whether HTTPS is enabled for the login server. Possible values include: - "Enabled", "Disabled". + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TlsStatus :ivar certificate: The certificate used to configure HTTPS for the login server. :vartype certificate: @@ -4339,22 +4115,18 @@ class TlsProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'certificate': {'readonly': True}, + "status": {"readonly": True}, + "certificate": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'TlsCertificateProperties'}, + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.certificate = None @@ -4374,8 +4146,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -4384,38 +4156,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -4425,11 +4197,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -4437,10 +4209,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -4453,23 +4225,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -4480,14 +4252,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar certificates: @@ -4499,15 +4271,15 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -4518,12 +4290,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -4534,17 +4306,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -4552,12 +4318,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4566,7 +4332,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPasswordName @@ -4575,14 +4341,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -4590,7 +4356,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -4598,26 +4364,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -4625,74 +4391,72 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -4702,64 +4466,56 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -4777,15 +4533,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4795,32 +4551,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4828,19 +4584,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4851,29 +4607,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4885,17 +4641,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -4905,23 +4661,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4932,7 +4688,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -4942,7 +4698,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -4953,17 +4709,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -4971,22 +4721,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4998,12 +4748,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5012,20 +4762,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5036,7 +4786,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_connected_registries_operations.py index 4b14b59a1e2d..8875bbd3d965 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_connected_registries_operations.py @@ -6,343 +6,371 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deactivate_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ConnectedRegistriesOperations(object): - """ConnectedRegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -350,72 +378,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -423,21 +553,25 @@ def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry 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 @@ -450,17 +584,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -469,93 +605,100 @@ def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -567,102 +710,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -670,21 +922,26 @@ def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -697,17 +954,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -716,47 +975,48 @@ def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -764,42 +1024,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -810,16 +1083,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,72 +1101,74 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace - def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -907,42 +1180,50 @@ def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deactivate_initial( + raw_result = self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_export_pipelines_operations.py index 54c69122beef..16415138a448 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_export_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_import_pipelines_operations.py index eceb4700d07b..22df0b167cce 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_import_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_operations.py index 8195196e5d91..0abe1ab1e357 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +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: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_pipeline_runs_operations.py index 31f32d234947..123b4c68b548 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_pipeline_runs_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +336,100 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -328,21 +437,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun 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 @@ -355,17 +468,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +489,74 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +566,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -472,95 +593,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +709,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +726,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_private_endpoint_connections_operations.py index 1d9ca7d14d30..c8c509ca6025 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,302 +6,341 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +348,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2020_11_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -328,22 +453,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2020_11_01_preview.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 :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 @@ -356,17 +485,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -375,65 +506,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -443,25 +583,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -473,95 +610,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -572,16 +729,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -591,8 +746,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_registries_operations.py index a21e1b007f43..abdb82fec9ce 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_registries_operations.py @@ -6,583 +6,556 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') - - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -592,28 +565,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ImportImageParameters 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 @@ -624,202 +674,287 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -827,36 +962,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry 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 @@ -868,17 +1076,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -886,63 +1096,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -952,22 +1172,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -979,80 +1195,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1060,37 +1300,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUpdateParameters 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 @@ -1102,17 +1420,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1120,76 +1440,93 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1200,16 +1537,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1219,49 +1554,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1272,16 +1621,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1291,247 +1638,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-11-01-preview") # type: str + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1542,16 +1989,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1561,47 +2006,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1610,34 +2071,114 @@ def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsParameters 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 @@ -1650,17 +2191,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1668,29 +2211,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_replications_operations.py index 06525bf601f4..8528c9f06bac 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_replications_operations.py @@ -6,348 +6,370 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +377,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +477,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication 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 @@ -400,17 +507,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +528,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +605,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -517,83 +632,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +740,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +841,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationUpdateParameters 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 @@ -647,17 +872,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -666,82 +893,96 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -752,16 +993,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -771,8 +1010,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py index ddd4b131528b..10a7cde2eab4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,21 +474,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap 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 @@ -400,17 +504,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +525,74 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +602,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -517,83 +629,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +737,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +836,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapUpdateParameters 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 @@ -646,17 +866,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -665,81 +887,96 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -750,16 +987,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -769,8 +1004,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_tokens_operations.py index e6a5807dc6e3..11cae193cc26 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_tokens_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,97 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +473,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token + 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 @@ -399,17 +503,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -418,65 +524,74 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -486,25 +601,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -516,83 +628,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -600,18 +736,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -619,21 +835,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenUpdateParameters 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 @@ -645,17 +865,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -664,81 +886,96 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -749,16 +986,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -768,8 +1003,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_webhooks_operations.py index a2fd7555575f..5d14d264117f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_webhooks_operations.py @@ -6,462 +6,482 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2020_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2020_11_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -469,18 +489,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -488,21 +588,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookCreateParameters 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 @@ -514,17 +618,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -533,65 +639,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -601,25 +716,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -631,83 +743,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -715,18 +851,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -734,21 +950,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookUpdateParameters 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 @@ -760,17 +980,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -779,81 +1001,96 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -864,16 +1101,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -883,191 +1118,209 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2020_11_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2020_11_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-11-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-11-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1078,16 +1331,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1097,8 +1348,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_configuration.py index b1bff34b4d6a..16b776767d72 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop("api_version", "2021-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_container_registry_management_client.py index 138baa60933b..701f7553a7aa 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -56,9 +68,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_06_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,31 +88,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -109,7 +126,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 @@ -122,15 +139,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_metadata.json index d7319e89fde8..eb2fd42dcaa0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "tokens": "TokensOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_configuration.py index a156ea8af4df..86c4cfd01ab4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop("api_version", "2021-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_container_registry_management_client.py index 0401f21ef739..ef1a4d026260 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -57,9 +69,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -77,31 +89,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -110,7 +127,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_connected_registries_operations.py index 99567fa2eb53..a9fd93f729d2 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_connected_registries_operations.py @@ -6,94 +6,118 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._connected_registries_operations import build_create_request_initial, build_deactivate_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConnectedRegistriesOperations: - """ConnectedRegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,72 +125,174 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -174,21 +300,25 @@ async def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry 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 @@ -201,17 +331,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -220,93 +352,100 @@ async def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -318,102 +457,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -421,21 +669,26 @@ async def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -448,17 +701,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -467,47 +722,48 @@ async def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -515,42 +771,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -561,16 +830,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -581,72 +848,74 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } async def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace_async - async def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -658,42 +927,50 @@ async def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deactivate_initial( + raw_result = await self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_export_pipelines_operations.py index 63acb485223b..5c3e924d6bec 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_import_pipelines_operations.py index 731a791e01c0..b435e3c78aac 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,40 +193,88 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 @@ -200,17 +287,59 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +348,74 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +425,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -317,95 +452,114 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +570,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +587,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_operations.py index b4838be83595..ebc1b5341ee0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_pipeline_runs_operations.py index 50f3d1d6302f..a807110d0510 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +294,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun 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 @@ -200,17 +325,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +346,74 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +423,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -317,95 +450,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -416,16 +566,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +583,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py index d1414ae36ba2..bca3d6d2063e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,147 +6,186 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +193,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_06_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -173,22 +298,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_06_01_preview.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 :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 @@ -201,17 +330,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -220,65 +351,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -288,25 +428,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -318,95 +455,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -417,16 +574,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -436,8 +591,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_registries_operations.py index 989193ad17d2..113d0c4cf9e7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_generate_credentials_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +134,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters 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 @@ -123,202 +243,287 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -326,36 +531,79 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 @@ -368,17 +616,51 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -386,63 +668,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -452,22 +744,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -479,80 +767,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -560,37 +872,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters 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 @@ -603,17 +995,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -621,76 +1015,93 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -701,16 +1112,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -720,49 +1129,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -773,16 +1196,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,247 +1213,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1043,16 +1564,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1062,47 +1581,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1111,34 +1646,114 @@ async def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters 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 @@ -1151,17 +1766,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1169,29 +1786,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_replications_operations.py index b843804d0bf1..c629b2eb82b0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_replications_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +294,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication 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 @@ -199,17 +324,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -218,65 +345,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,25 +422,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -316,83 +449,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -400,18 +557,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -419,21 +658,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters 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 @@ -446,17 +689,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -465,82 +710,96 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +810,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +827,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_scope_maps_operations.py index 1d6212fab2b7..0849db73b387 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_scope_maps_operations.py @@ -6,147 +6,187 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +194,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +295,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap 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 @@ -200,17 +326,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +347,74 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +424,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -317,83 +451,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +559,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +660,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters 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 @@ -447,17 +691,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +712,96 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +812,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,8 +829,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_tokens_operations.py index d43bdec3ac3a..41d9688be436 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_tokens_operations.py @@ -6,147 +6,185 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +192,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,20 +290,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token + 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 @@ -198,17 +320,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -217,65 +341,74 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -285,25 +418,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -315,83 +445,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -399,18 +553,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -418,21 +652,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters 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 @@ -444,17 +682,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -463,81 +703,96 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -548,16 +803,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -567,8 +820,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_webhooks_operations.py index fb6b030002fc..c94c3df4e07e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_webhooks_operations.py @@ -6,147 +6,190 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -154,18 +197,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -173,21 +298,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters 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 @@ -200,17 +329,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -219,65 +350,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -287,25 +427,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -317,83 +454,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -401,18 +562,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -420,21 +663,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters 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 @@ -447,17 +694,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -466,81 +715,96 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -551,16 +815,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -570,191 +832,211 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -765,16 +1047,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -784,8 +1064,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/__init__.py index 51c980de1cff..28e358371de5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/__init__.py @@ -111,187 +111,189 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActivationProperties', - 'ActiveDirectoryObject', - 'Actor', - 'CallbackConfig', - 'ConnectedRegistry', - 'ConnectedRegistryListResult', - 'ConnectedRegistryUpdateParameters', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'ExportPolicy', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'LoggingProperties', - 'LoginServerProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'ParentProperties', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'Sku', - 'Source', - 'Status', - 'StatusDetailProperties', - 'SyncProperties', - 'SyncUpdateProperties', - 'SystemData', - 'Target', - 'TlsCertificateProperties', - 'TlsProperties', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'TrustPolicy', - 'UserIdentityProperties', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ActivationStatus', - 'AuditLogStatus', - 'CertificateType', - 'ConnectedRegistryMode', - 'ConnectionState', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ExportPolicyStatus', - 'ImportMode', - 'LastModifiedByType', - 'LogLevel', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TlsStatus', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "Source", + "Status", + "StatusDetailProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_container_registry_management_client_enums.py index 783d26c6cacf..e4b14b90779c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_container_registry_management_client_enums.py @@ -7,99 +7,98 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ActivationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The activation status of the connected registry. - """ + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" ACTIVE = "Active" INACTIVE = "Inactive" -class AuditLogStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether audit logs are enabled on the connected registry. - """ + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class CertificateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of certificate location. - """ + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" LOCAL_DIRECTORY = "LocalDirectory" -class ConnectedRegistryMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The mode of the connected registry resource that indicates the permissions of the registry. - """ + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" REGISTRY = "Registry" MIRROR = "Mirror" -class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current connection state of the connected registry. - """ + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" ONLINE = "Online" OFFLINE = "Offline" SYNCING = "Syncing" UNHEALTHY = "Unhealthy" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ExportPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -107,18 +106,18 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity of logs persisted on the connected registry. - """ + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" DEBUG = "Debug" INFORMATION = "Information" @@ -126,55 +125,57 @@ class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" NONE = "None" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -183,87 +184,91 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TlsStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether HTTPS is enabled for the login server. - """ + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -271,16 +276,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_models_py3.py index 51006041b011..68dd4907067e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/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. @@ -7,44 +8,41 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActivationProperties(msrest.serialization.Model): +class ActivationProperties(_serialization.Model): """The activation properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The activation status of the connected registry. Possible values include: - "Active", "Inactive". + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ActivationStatus """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ActivationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -56,17 +54,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -75,12 +67,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -89,63 +81,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -161,33 +142,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ConnectedRegistry(ProxyResource): +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes """An object that represents a connected registry for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -200,18 +177,18 @@ class ConnectedRegistry(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState :ivar mode: The mode of the connected registry resource that indicates the permissions of the - registry. Possible values include: "Registry", "Mirror". + registry. Known values are: "Registry" and "Mirror". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryMode :ivar version: The current version of ACR runtime on the connected registry. :vartype version: str - :ivar connection_state: The current connection state of the connected registry. Possible values - include: "Online", "Offline", "Syncing", "Unhealthy". + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". :vartype connection_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectionState :ivar last_activity_time: The last activity time of the connected registry. @@ -235,49 +212,49 @@ class ConnectedRegistry(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'connection_state': {'readonly': True}, - 'last_activity_time': {'readonly': True}, - 'activation': {'readonly': True}, - 'status_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'connection_state': {'key': 'properties.connectionState', 'type': 'str'}, - 'last_activity_time': {'key': 'properties.lastActivityTime', 'type': 'iso-8601'}, - 'activation': {'key': 'properties.activation', 'type': 'ActivationProperties'}, - 'parent': {'key': 'properties.parent', 'type': 'ParentProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'LoginServerProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'status_details': {'key': 'properties.statusDetails', 'type': '[StatusDetailProperties]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, } def __init__( self, *, - mode: Optional[Union[str, "ConnectedRegistryMode"]] = None, - parent: Optional["ParentProperties"] = None, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, client_token_ids: Optional[List[str]] = None, - login_server: Optional["LoginServerProperties"] = None, - logging: Optional["LoggingProperties"] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, **kwargs ): """ :keyword mode: The mode of the connected registry resource that indicates the permissions of - the registry. Possible values include: "Registry", "Mirror". + the registry. Known values are: "Registry" and "Mirror". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryMode :keyword parent: The parent of the connected registry. @@ -291,7 +268,7 @@ def __init__( :keyword logging: The logging properties of the connected registry. :paramtype logging: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LoggingProperties """ - super(ConnectedRegistry, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.mode = mode self.version = None @@ -305,7 +282,7 @@ def __init__( self.status_details = None -class ConnectedRegistryListResult(msrest.serialization.Model): +class ConnectedRegistryListResult(_serialization.Model): """The result of a request to list connected registries for a container registry. :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink @@ -317,16 +294,12 @@ class ConnectedRegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectedRegistry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ConnectedRegistry"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of connected registries. Since this list may be incomplete, the @@ -336,12 +309,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of connected registries. :paramtype next_link: str """ - super(ConnectedRegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConnectedRegistryUpdateParameters(msrest.serialization.Model): +class ConnectedRegistryUpdateParameters(_serialization.Model): """The parameters for updating a connected registry. :ivar sync_properties: The sync properties of the connected registry with its parent. @@ -355,16 +328,16 @@ class ConnectedRegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sync_properties': {'key': 'properties.syncProperties', 'type': 'SyncUpdateProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, } def __init__( self, *, - sync_properties: Optional["SyncUpdateProperties"] = None, - logging: Optional["LoggingProperties"] = None, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, client_token_ids: Optional[List[str]] = None, **kwargs ): @@ -378,17 +351,17 @@ def __init__( to the connected registry. :paramtype client_token_ids: list[str] """ - super(ConnectedRegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sync_properties = sync_properties self.logging = logging self.client_token_ids = client_token_ids -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -397,32 +370,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -430,31 +403,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -465,15 +433,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -482,13 +450,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -497,14 +465,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -512,20 +480,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -543,17 +506,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -566,12 +529,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -593,25 +556,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -632,7 +595,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -642,7 +605,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -653,17 +616,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -671,12 +628,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -692,17 +649,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -721,7 +678,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -729,7 +686,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -745,11 +702,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -774,7 +731,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -806,39 +763,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -854,7 +811,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -862,7 +819,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -873,16 +830,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -891,12 +844,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -907,29 +860,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -937,46 +883,41 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ExportPolicy(msrest.serialization.Model): +class ExportPolicy(_serialization.Model): """The export policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "ExportPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPolicyStatus """ - super(ExportPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -985,15 +926,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1001,7 +942,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -1011,17 +952,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -1032,16 +973,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1050,20 +987,20 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1076,10 +1013,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1087,8 +1024,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1096,8 +1033,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1108,19 +1045,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2021_06_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1129,33 +1066,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1164,11 +1101,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -1202,41 +1139,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -1255,7 +1192,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -1264,7 +1201,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1275,16 +1212,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1293,67 +1226,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -1365,22 +1296,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -1389,7 +1320,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -1400,144 +1331,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1556,33 +1468,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1590,45 +1496,45 @@ def __init__( self.last_key_rotation_timestamp = None -class LoggingProperties(msrest.serialization.Model): +class LoggingProperties(_serialization.Model): """The logging properties of the connected registry. - :ivar log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". :vartype log_level: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LogLevel :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :vartype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.AuditLogStatus """ _attribute_map = { - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'audit_log_status': {'key': 'auditLogStatus', 'type': 'str'}, + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, } def __init__( self, *, - log_level: Optional[Union[str, "LogLevel"]] = "Information", - audit_log_status: Optional[Union[str, "AuditLogStatus"]] = "Disabled", + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", **kwargs ): """ - :keyword log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". :paramtype log_level: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LogLevel :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :paramtype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.AuditLogStatus """ - super(LoggingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_level = log_level self.audit_log_status = audit_log_status -class LoginServerProperties(msrest.serialization.Model): +class LoginServerProperties(_serialization.Model): """The login server properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1640,33 +1546,29 @@ class LoginServerProperties(msrest.serialization.Model): """ _validation = { - 'host': {'readonly': True}, - 'tls': {'readonly': True}, + "host": {"readonly": True}, + "tls": {"readonly": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'tls': {'key': 'tls', 'type': 'TlsProperties'}, + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LoginServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.host = None self.tls = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. @@ -1677,26 +1579,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -1705,13 +1607,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1731,11 +1633,14 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1743,9 +1648,9 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1764,7 +1669,7 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display @@ -1772,7 +1677,7 @@ def __init__( self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1786,10 +1691,10 @@ class OperationDisplayDefinition(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__( @@ -1811,14 +1716,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1831,16 +1736,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1851,12 +1752,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1868,9 +1769,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1889,13 +1790,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1913,12 +1814,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1946,7 +1847,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1955,7 +1856,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1967,15 +1868,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -1986,48 +1887,48 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class ParentProperties(msrest.serialization.Model): +class ParentProperties(_serialization.Model): """The properties of the connected registry parent. All required parameters must be populated in order to send to Azure. :ivar id: The resource ID of the parent to which the connected registry will be associated. :vartype id: str - :ivar sync_properties: Required. The sync properties of the connected registry with its parent. + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. :vartype sync_properties: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SyncProperties """ _validation = { - 'sync_properties': {'required': True}, + "sync_properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'sync_properties': {'key': 'syncProperties', 'type': 'SyncProperties'}, + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, } def __init__( self, *, - sync_properties: "SyncProperties", - id: Optional[str] = None, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: The resource ID of the parent to which the connected registry will be associated. :paramtype id: str - :keyword sync_properties: Required. The sync properties of the connected registry with its - parent. + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. :paramtype sync_properties: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SyncProperties """ - super(ParentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.sync_properties = sync_properties @@ -2045,8 +1946,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -2059,29 +1960,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -2092,14 +1993,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -2110,16 +2011,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -2128,12 +2025,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -2154,11 +2051,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -2166,8 +2063,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -2188,7 +2085,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -2196,7 +2093,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -2226,16 +2123,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -2243,13 +2140,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -2280,7 +2177,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -2293,11 +2190,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -2305,35 +2201,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -2341,31 +2235,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -2373,58 +2266,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -2433,25 +2316,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -2460,25 +2338,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -2494,19 +2367,19 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - 'export_policy': {'key': 'exportPolicy', 'type': 'ExportPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, - export_policy: Optional["ExportPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, **kwargs ): """ @@ -2521,14 +2394,14 @@ def __init__( :keyword export_policy: The export policy for a container registry. :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy self.export_policy = export_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -2536,21 +2409,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -2574,35 +2442,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2614,13 +2485,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_06_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2633,14 +2504,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2653,12 +2524,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2678,22 +2549,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2712,7 +2583,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2721,7 +2592,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2733,16 +2604,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2753,61 +2620,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2815,84 +2682,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2905,47 +2757,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2954,7 +2800,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2967,14 +2813,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.IdentityProperties @@ -2983,8 +2829,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -3009,15 +2855,15 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ZoneRedundancy :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3025,71 +2871,74 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, - anonymous_pull_enabled: Optional[bool] = False, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -3107,21 +2956,21 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ZoneRedundancy :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -3141,7 +2990,7 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -3152,16 +3001,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -3170,12 +3015,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -3186,17 +3031,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -3204,53 +3043,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -3263,9 +3097,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -3285,50 +3119,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Sku @@ -3345,11 +3175,11 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.NetworkRuleBypassOptions :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3357,32 +3187,32 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, anonymous_pull_enabled: Optional[bool] = None, **kwargs ): @@ -3390,7 +3220,7 @@ def __init__( :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Sku @@ -3407,17 +3237,17 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.NetworkRuleBypassOptions :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -3431,25 +3261,25 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -3458,28 +3288,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -3487,20 +3317,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3517,15 +3342,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState @@ -3536,32 +3361,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -3569,33 +3394,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3606,16 +3431,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3624,15 +3445,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -3641,31 +3462,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3683,17 +3500,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3714,7 +3531,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3722,7 +3539,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3731,36 +3548,30 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status @@ -3785,8 +3596,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -3796,34 +3607,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3832,7 +3637,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -3840,7 +3645,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -3851,17 +3656,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -3869,12 +3668,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -3886,17 +3685,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3905,53 +3698,48 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -3962,17 +3750,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -3980,12 +3762,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -3999,30 +3781,26 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StatusDetailProperties(msrest.serialization.Model): +class StatusDetailProperties(_serialization.Model): """The status detail properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4040,28 +3818,24 @@ class StatusDetailProperties(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'code': {'readonly': True}, - 'description': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'correlation_id': {'readonly': True}, + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StatusDetailProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.code = None self.description = None @@ -4069,15 +3843,15 @@ def __init__( self.correlation_id = None -class SyncProperties(msrest.serialization.Model): +class SyncProperties(_serialization.Model): """The sync properties of the connected registry with its parent. 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 token_id: Required. The resource ID of the ACR token used to authenticate the connected - registry to its parent during sync. + :ivar token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. :vartype token_id: str :ivar schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4085,8 +3859,9 @@ class SyncProperties(msrest.serialization.Model): :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :vartype sync_window: ~datetime.timedelta - :ivar message_ttl: Required. The period of time for which a message is available to sync before - it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :vartype message_ttl: ~datetime.timedelta :ivar last_sync_time: The last time a sync occurred between the connected registry and its parent. @@ -4097,19 +3872,19 @@ class SyncProperties(msrest.serialization.Model): """ _validation = { - 'token_id': {'required': True}, - 'message_ttl': {'required': True}, - 'last_sync_time': {'readonly': True}, - 'gateway_endpoint': {'readonly': True}, + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'gateway_endpoint': {'key': 'gatewayEndpoint', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, } def __init__( @@ -4122,8 +3897,8 @@ def __init__( **kwargs ): """ - :keyword token_id: Required. The resource ID of the ACR token used to authenticate the - connected registry to its parent during sync. + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. :paramtype token_id: str :keyword schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4131,12 +3906,12 @@ def __init__( :keyword sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype sync_window: ~datetime.timedelta - :keyword message_ttl: Required. The period of time for which a message is available to sync - before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per - ISO8601. + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.schedule = schedule self.sync_window = sync_window @@ -4145,7 +3920,7 @@ def __init__( self.gateway_endpoint = None -class SyncUpdateProperties(msrest.serialization.Model): +class SyncUpdateProperties(_serialization.Model): """The parameters for updating the sync properties of the connected registry with its parent. :ivar schedule: The cron expression indicating the schedule that the connected registry will @@ -4160,9 +3935,9 @@ class SyncUpdateProperties(msrest.serialization.Model): """ _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, } def __init__( @@ -4184,27 +3959,27 @@ def __init__( expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncUpdateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.sync_window = sync_window self.message_ttl = message_ttl -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -4212,44 +3987,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -4258,17 +4033,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -4282,15 +4057,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -4311,12 +4086,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -4328,7 +4103,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -4340,45 +4115,41 @@ def __init__( self.version = version -class TlsCertificateProperties(msrest.serialization.Model): +class TlsCertificateProperties(_serialization.Model): """The TLS certificate properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of certificate location. Possible values include: "LocalDirectory". + :ivar type: The type of certificate location. "LocalDirectory" :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.CertificateType :ivar location: Indicates the location of the certificates. :vartype location: str """ _validation = { - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsCertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.location = None -class TlsProperties(msrest.serialization.Model): +class TlsProperties(_serialization.Model): """The TLS properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Indicates whether HTTPS is enabled for the login server. Possible values include: - "Enabled", "Disabled". + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TlsStatus :ivar certificate: The certificate used to configure HTTPS for the login server. :vartype certificate: @@ -4386,22 +4157,18 @@ class TlsProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'certificate': {'readonly': True}, + "status": {"readonly": True}, + "certificate": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'TlsCertificateProperties'}, + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.certificate = None @@ -4421,8 +4188,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -4431,38 +4198,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -4472,11 +4239,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -4484,10 +4251,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -4500,23 +4267,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -4527,14 +4294,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar certificates: @@ -4546,15 +4313,15 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -4565,12 +4332,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -4581,17 +4348,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -4599,12 +4360,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4613,7 +4374,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPasswordName @@ -4622,14 +4383,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -4637,7 +4398,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -4645,26 +4406,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -4672,74 +4433,72 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -4749,64 +4508,56 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -4824,15 +4575,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4842,32 +4593,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4875,19 +4626,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4898,29 +4649,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4932,17 +4683,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -4952,23 +4703,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4979,7 +4730,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -4989,7 +4740,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -5000,17 +4751,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -5018,22 +4763,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -5045,12 +4790,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5059,20 +4804,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5083,7 +4828,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_connected_registries_operations.py index fb3d2aa5bf91..f96173661e23 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_connected_registries_operations.py @@ -6,343 +6,371 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deactivate_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ConnectedRegistriesOperations(object): - """ConnectedRegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -350,72 +378,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -423,21 +553,25 @@ def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry 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 @@ -450,17 +584,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -469,93 +605,100 @@ def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -567,102 +710,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -670,21 +922,26 @@ def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -697,17 +954,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -716,47 +975,48 @@ def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -764,42 +1024,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -810,16 +1083,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,72 +1101,74 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace - def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -907,42 +1180,50 @@ def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deactivate_initial( + raw_result = self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_export_pipelines_operations.py index 9dd77e0e9fe2..f7dbc8c1b714 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_export_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_import_pipelines_operations.py index a4d989d731e5..43e80dcad3af 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_import_pipelines_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,40 +336,128 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline 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 @@ -355,17 +470,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +491,74 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +568,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -472,95 +595,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +711,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +728,8 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_operations.py index 9ac542750d5a..161152da3941 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_pipeline_runs_operations.py index 34e23a83f43f..5ddcd9b85b8b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_pipeline_runs_operations.py @@ -6,302 +6,329 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +336,100 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -328,21 +437,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun 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 @@ -355,17 +468,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -374,65 +489,74 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -442,25 +566,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -472,95 +593,112 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -571,16 +709,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -590,8 +726,8 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py index 8e8bca7ae2da..bd782438dd0c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,302 +6,341 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,18 +348,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_06_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -328,22 +453,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_06_01_preview.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 :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 @@ -356,17 +485,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -375,65 +506,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -443,25 +583,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -473,95 +610,115 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -572,16 +729,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -591,8 +746,8 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_registries_operations.py index a5117b294b87..1b98f63f2c8e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_registries_operations.py @@ -6,583 +6,556 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') - - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -592,28 +565,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters 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 @@ -624,202 +674,287 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -827,36 +962,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry 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 @@ -868,17 +1076,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -886,63 +1096,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -952,22 +1172,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -979,80 +1195,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1060,37 +1300,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters 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 @@ -1102,17 +1420,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1120,76 +1440,93 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1200,16 +1537,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1219,49 +1554,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1272,16 +1621,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1291,247 +1638,347 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1542,16 +1989,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1561,47 +2006,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1610,34 +2071,114 @@ def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters 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 @@ -1650,17 +2191,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1668,29 +2211,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_replications_operations.py index 349bf151c0f8..9e565833128b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_replications_operations.py @@ -6,348 +6,370 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +377,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +477,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication 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 @@ -400,17 +507,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +528,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +605,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -517,83 +632,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +740,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +841,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters 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 @@ -647,17 +872,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -666,82 +893,96 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -752,16 +993,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -771,8 +1010,8 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_scope_maps_operations.py index 0917ead1a934..c37548d6d374 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_scope_maps_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,21 +474,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap 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 @@ -400,17 +504,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -419,65 +525,74 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -487,25 +602,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -517,83 +629,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -601,18 +737,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -620,21 +836,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters 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 @@ -646,17 +866,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -665,81 +887,96 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -750,16 +987,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -769,8 +1004,8 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_tokens_operations.py index e115a0799d1b..9346b8203764 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_tokens_operations.py @@ -6,348 +6,368 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,18 +375,97 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -374,20 +473,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token + 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 @@ -399,17 +503,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -418,65 +524,74 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -486,25 +601,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -516,83 +628,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -600,18 +736,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -619,21 +835,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters 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 @@ -645,17 +865,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -664,81 +886,96 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -749,16 +986,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -768,8 +1003,8 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_webhooks_operations.py index 0e562371a949..daad5c1056fa 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_webhooks_operations.py @@ -6,462 +6,482 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_06_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -469,18 +489,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -488,21 +588,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters 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 @@ -514,17 +618,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -533,65 +639,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -601,25 +716,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -631,83 +743,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -715,18 +851,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -734,21 +950,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters 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 @@ -760,17 +980,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -779,81 +1001,96 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -864,16 +1101,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -883,191 +1118,209 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_06_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1078,16 +1331,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1097,8 +1348,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_configuration.py index 08d315733ab9..81c91c9f5a1e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-08-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop("api_version", "2021-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_container_registry_management_client.py index 6cc55c0d31ab..12b72153e3d6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -56,9 +68,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_08_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,31 +88,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -109,7 +126,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 @@ -122,15 +139,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_metadata.json index cff99a3e0e7d..0a3da9fe0d98 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "tokens": "TokensOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_configuration.py index e6140093858a..b368036e0d7a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-08-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop("api_version", "2021-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_container_registry_management_client.py index 1efddc8c68b3..5fef22161dd0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -57,9 +69,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_08_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -77,31 +89,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -110,7 +127,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_connected_registries_operations.py index 064c6a6c2f1b..6090fc64924d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_connected_registries_operations.py @@ -6,61 +6,77 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._connected_registries_operations import build_create_request_initial, build_deactivate_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConnectedRegistriesOperations: - """ConnectedRegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -68,42 +84,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -114,16 +143,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,59 +161,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,72 +225,174 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -267,21 +400,25 @@ async def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry 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 @@ -294,17 +431,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -313,93 +452,100 @@ async def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -411,102 +557,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -514,21 +769,26 @@ async def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -541,17 +801,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -560,93 +822,100 @@ async def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace_async - async def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -658,42 +927,50 @@ async def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deactivate_initial( + raw_result = await self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_export_pipelines_operations.py index e5e9338193a3..fa5f454b6328 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +152,133 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,40 +286,47 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline + :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 @@ -284,17 +339,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -303,65 +441,74 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,25 +518,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -401,42 +545,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_import_pipelines_operations.py index 487728c1b028..47119d2ab395 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +152,133 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,40 +286,47 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline + :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 @@ -284,17 +339,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -303,65 +441,74 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,25 +518,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -401,42 +545,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_operations.py index 7adbe72ffdb9..53c281787405 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_pipeline_runs_operations.py index 3e0e751780bd..edff7a1bd910 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,96 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +150,133 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +284,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -257,21 +385,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun 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 @@ -284,17 +416,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -303,65 +437,74 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,25 +514,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -401,42 +541,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_private_endpoint_connections_operations.py index 7bb1639b8801..d060ce36bd92 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,96 +6,126 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +136,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +153,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +287,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_08_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -257,22 +392,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_08_01_preview.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 :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 @@ -285,17 +424,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -304,65 +445,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,25 +522,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -402,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_registries_operations.py index ae45e6cbc2c1..e179d03d1d15 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_generate_credentials_request_initial, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +134,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters 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 @@ -123,145 +243,228 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -272,16 +475,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -291,55 +492,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -350,16 +561,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -369,106 +578,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -476,36 +701,42 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry + :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 @@ -518,17 +749,88 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -536,63 +838,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -602,22 +914,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -629,80 +937,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -710,37 +1042,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters 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 @@ -753,17 +1165,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -771,141 +1185,163 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -916,16 +1352,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -935,174 +1369,275 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1111,34 +1646,114 @@ async def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters 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 @@ -1151,17 +1766,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1169,29 +1786,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_replications_operations.py index 44ab606a0403..41e4c2b757a6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_replications_operations.py @@ -6,96 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +151,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +285,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -257,20 +385,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication 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 @@ -283,17 +415,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +436,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +513,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -400,83 +540,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +648,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +749,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters 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 @@ -530,17 +780,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,29 +801,34 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_scope_maps_operations.py index 632dcc163003..a785d526e0ba 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_scope_maps_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +151,133 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +285,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,21 +386,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap 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 @@ -283,17 +417,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +438,74 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +515,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -400,83 +542,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +650,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +751,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters 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 @@ -530,17 +782,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,29 +803,34 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_tokens_operations.py index 1c18062c48b0..9997941bd24a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_tokens_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +151,131 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +283,97 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,20 +381,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token + 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 @@ -281,17 +411,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -300,65 +432,74 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -368,25 +509,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -398,83 +536,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -482,18 +644,98 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -501,21 +743,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters 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 @@ -527,17 +773,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -546,29 +794,34 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_webhooks_operations.py index 64645cffe422..7e78576517e8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/aio/operations/_webhooks_operations.py @@ -6,95 +6,127 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +154,133 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +288,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,21 +389,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters 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 @@ -283,17 +420,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +441,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +518,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -400,83 +545,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +653,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +754,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters 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 @@ -530,17 +785,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,149 +806,169 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -702,16 +979,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,71 +996,76 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/__init__.py index 51c980de1cff..28e358371de5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/__init__.py @@ -111,187 +111,189 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActivationProperties', - 'ActiveDirectoryObject', - 'Actor', - 'CallbackConfig', - 'ConnectedRegistry', - 'ConnectedRegistryListResult', - 'ConnectedRegistryUpdateParameters', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'ExportPolicy', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'LoggingProperties', - 'LoginServerProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'ParentProperties', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'Sku', - 'Source', - 'Status', - 'StatusDetailProperties', - 'SyncProperties', - 'SyncUpdateProperties', - 'SystemData', - 'Target', - 'TlsCertificateProperties', - 'TlsProperties', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'TrustPolicy', - 'UserIdentityProperties', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ActivationStatus', - 'AuditLogStatus', - 'CertificateType', - 'ConnectedRegistryMode', - 'ConnectionState', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ExportPolicyStatus', - 'ImportMode', - 'LastModifiedByType', - 'LogLevel', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TlsStatus', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "Source", + "Status", + "StatusDetailProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_container_registry_management_client_enums.py index 0c0448c6db6f..51a3b9c4423a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_container_registry_management_client_enums.py @@ -7,101 +7,100 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ActivationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The activation status of the connected registry. - """ + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" ACTIVE = "Active" INACTIVE = "Inactive" -class AuditLogStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether audit logs are enabled on the connected registry. - """ + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class CertificateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of certificate location. - """ + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" LOCAL_DIRECTORY = "LocalDirectory" -class ConnectedRegistryMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The mode of the connected registry resource that indicates the permissions of the registry. - """ + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" READ_WRITE = "ReadWrite" READ_ONLY = "ReadOnly" REGISTRY = "Registry" MIRROR = "Mirror" -class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current connection state of the connected registry. - """ + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" ONLINE = "Online" OFFLINE = "Offline" SYNCING = "Syncing" UNHEALTHY = "Unhealthy" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ExportPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -109,18 +108,18 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity of logs persisted on the connected registry. - """ + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" DEBUG = "Debug" INFORMATION = "Information" @@ -128,55 +127,57 @@ class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" NONE = "None" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -185,87 +186,91 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TlsStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether HTTPS is enabled for the login server. - """ + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -273,16 +278,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_models_py3.py index 5e107e6cec76..6b0318340f6d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/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. @@ -7,44 +8,41 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActivationProperties(msrest.serialization.Model): +class ActivationProperties(_serialization.Model): """The activation properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The activation status of the connected registry. Possible values include: - "Active", "Inactive". + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ActivationStatus """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ActivationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -56,17 +54,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -75,12 +67,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -89,63 +81,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -161,33 +142,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ConnectedRegistry(ProxyResource): +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes """An object that represents a connected registry for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -200,18 +177,18 @@ class ConnectedRegistry(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState :ivar mode: The mode of the connected registry resource that indicates the permissions of the - registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryMode :ivar version: The current version of ACR runtime on the connected registry. :vartype version: str - :ivar connection_state: The current connection state of the connected registry. Possible values - include: "Online", "Offline", "Syncing", "Unhealthy". + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". :vartype connection_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectionState :ivar last_activity_time: The last activity time of the connected registry. @@ -238,51 +215,51 @@ class ConnectedRegistry(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'connection_state': {'readonly': True}, - 'last_activity_time': {'readonly': True}, - 'activation': {'readonly': True}, - 'status_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'connection_state': {'key': 'properties.connectionState', 'type': 'str'}, - 'last_activity_time': {'key': 'properties.lastActivityTime', 'type': 'iso-8601'}, - 'activation': {'key': 'properties.activation', 'type': 'ActivationProperties'}, - 'parent': {'key': 'properties.parent', 'type': 'ParentProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'LoginServerProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'status_details': {'key': 'properties.statusDetails', 'type': '[StatusDetailProperties]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - mode: Optional[Union[str, "ConnectedRegistryMode"]] = None, - parent: Optional["ParentProperties"] = None, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, client_token_ids: Optional[List[str]] = None, - login_server: Optional["LoginServerProperties"] = None, - logging: Optional["LoggingProperties"] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, notifications_list: Optional[List[str]] = None, **kwargs ): """ :keyword mode: The mode of the connected registry resource that indicates the permissions of - the registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + the registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryMode :keyword parent: The parent of the connected registry. @@ -299,7 +276,7 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistry, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.mode = mode self.version = None @@ -314,7 +291,7 @@ def __init__( self.notifications_list = notifications_list -class ConnectedRegistryListResult(msrest.serialization.Model): +class ConnectedRegistryListResult(_serialization.Model): """The result of a request to list connected registries for a container registry. :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink @@ -326,16 +303,12 @@ class ConnectedRegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectedRegistry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ConnectedRegistry"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of connected registries. Since this list may be incomplete, the @@ -345,12 +318,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of connected registries. :paramtype next_link: str """ - super(ConnectedRegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConnectedRegistryUpdateParameters(msrest.serialization.Model): +class ConnectedRegistryUpdateParameters(_serialization.Model): """The parameters for updating a connected registry. :ivar sync_properties: The sync properties of the connected registry with its parent. @@ -367,17 +340,17 @@ class ConnectedRegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sync_properties': {'key': 'properties.syncProperties', 'type': 'SyncUpdateProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - sync_properties: Optional["SyncUpdateProperties"] = None, - logging: Optional["LoggingProperties"] = None, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, client_token_ids: Optional[List[str]] = None, notifications_list: Optional[List[str]] = None, **kwargs @@ -395,18 +368,18 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sync_properties = sync_properties self.logging = logging self.client_token_ids = client_token_ids self.notifications_list = notifications_list -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -415,32 +388,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -448,31 +421,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -483,15 +451,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -500,13 +468,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -515,14 +483,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -530,20 +498,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -561,17 +524,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -584,12 +547,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -611,25 +574,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -650,7 +613,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -660,7 +623,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -671,17 +634,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -689,12 +646,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -710,17 +667,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -739,7 +696,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -747,7 +704,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -763,11 +720,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -792,7 +749,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -824,39 +781,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -872,7 +829,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -880,7 +837,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -891,16 +848,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -909,12 +862,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -925,29 +878,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -955,46 +901,41 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ExportPolicy(msrest.serialization.Model): +class ExportPolicy(_serialization.Model): """The export policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "ExportPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPolicyStatus """ - super(ExportPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -1003,15 +944,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1019,7 +960,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -1029,17 +970,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -1050,16 +991,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1068,20 +1005,20 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1094,10 +1031,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1105,8 +1042,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1114,8 +1051,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1126,19 +1063,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2021_08_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1147,33 +1084,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1182,11 +1119,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -1220,41 +1157,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -1273,7 +1210,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -1282,7 +1219,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1293,16 +1230,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1311,67 +1244,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -1383,22 +1314,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -1407,7 +1338,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -1418,144 +1349,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1574,33 +1486,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1608,45 +1514,45 @@ def __init__( self.last_key_rotation_timestamp = None -class LoggingProperties(msrest.serialization.Model): +class LoggingProperties(_serialization.Model): """The logging properties of the connected registry. - :ivar log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". :vartype log_level: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.LogLevel :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :vartype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.AuditLogStatus """ _attribute_map = { - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'audit_log_status': {'key': 'auditLogStatus', 'type': 'str'}, + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, } def __init__( self, *, - log_level: Optional[Union[str, "LogLevel"]] = "Information", - audit_log_status: Optional[Union[str, "AuditLogStatus"]] = "Disabled", + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", **kwargs ): """ - :keyword log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". :paramtype log_level: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.LogLevel :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :paramtype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.AuditLogStatus """ - super(LoggingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_level = log_level self.audit_log_status = audit_log_status -class LoginServerProperties(msrest.serialization.Model): +class LoginServerProperties(_serialization.Model): """The login server properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1658,33 +1564,29 @@ class LoginServerProperties(msrest.serialization.Model): """ _validation = { - 'host': {'readonly': True}, - 'tls': {'readonly': True}, + "host": {"readonly": True}, + "tls": {"readonly": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'tls': {'key': 'tls', 'type': 'TlsProperties'}, + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LoginServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.host = None self.tls = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. @@ -1695,26 +1597,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -1723,13 +1625,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1749,11 +1651,14 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1761,9 +1666,9 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1782,7 +1687,7 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display @@ -1790,7 +1695,7 @@ def __init__( self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1804,10 +1709,10 @@ class OperationDisplayDefinition(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__( @@ -1829,14 +1734,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1849,16 +1754,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1869,12 +1770,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1886,9 +1787,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1907,13 +1808,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1931,12 +1832,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1964,7 +1865,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1973,7 +1874,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1985,15 +1886,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -2004,48 +1905,48 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class ParentProperties(msrest.serialization.Model): +class ParentProperties(_serialization.Model): """The properties of the connected registry parent. All required parameters must be populated in order to send to Azure. :ivar id: The resource ID of the parent to which the connected registry will be associated. :vartype id: str - :ivar sync_properties: Required. The sync properties of the connected registry with its parent. + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. :vartype sync_properties: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SyncProperties """ _validation = { - 'sync_properties': {'required': True}, + "sync_properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'sync_properties': {'key': 'syncProperties', 'type': 'SyncProperties'}, + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, } def __init__( self, *, - sync_properties: "SyncProperties", - id: Optional[str] = None, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: The resource ID of the parent to which the connected registry will be associated. :paramtype id: str - :keyword sync_properties: Required. The sync properties of the connected registry with its - parent. + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. :paramtype sync_properties: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SyncProperties """ - super(ParentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.sync_properties = sync_properties @@ -2063,8 +1964,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -2077,29 +1978,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -2110,14 +2011,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -2128,16 +2029,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -2146,12 +2043,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -2172,11 +2069,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -2184,8 +2081,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -2206,7 +2103,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -2214,7 +2111,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -2244,16 +2141,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -2261,13 +2158,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -2298,7 +2195,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -2311,11 +2208,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -2323,35 +2219,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -2359,31 +2253,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -2391,58 +2284,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -2451,25 +2334,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -2478,25 +2356,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -2512,19 +2385,19 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - 'export_policy': {'key': 'exportPolicy', 'type': 'ExportPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, - export_policy: Optional["ExportPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, **kwargs ): """ @@ -2539,14 +2412,14 @@ def __init__( :keyword export_policy: The export policy for a container registry. :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy self.export_policy = export_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -2554,21 +2427,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -2592,35 +2460,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2632,13 +2503,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_08_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2651,14 +2522,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2671,12 +2542,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2696,22 +2567,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2730,7 +2601,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2739,7 +2610,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2751,16 +2622,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2771,61 +2638,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2833,84 +2700,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2923,47 +2775,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2972,7 +2818,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2985,14 +2831,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.IdentityProperties @@ -3001,8 +2847,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -3027,15 +2873,15 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ZoneRedundancy :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3043,71 +2889,74 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, - anonymous_pull_enabled: Optional[bool] = False, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -3125,21 +2974,21 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ZoneRedundancy :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -3159,7 +3008,7 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -3170,16 +3019,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -3188,12 +3033,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -3204,17 +3049,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -3222,53 +3061,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -3281,9 +3115,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -3303,50 +3137,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Sku @@ -3363,11 +3193,11 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.NetworkRuleBypassOptions :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3375,32 +3205,32 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, anonymous_pull_enabled: Optional[bool] = None, **kwargs ): @@ -3408,7 +3238,7 @@ def __init__( :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Sku @@ -3425,17 +3255,17 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.NetworkRuleBypassOptions :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -3449,25 +3279,25 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -3476,28 +3306,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -3505,20 +3335,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3535,15 +3360,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState @@ -3554,32 +3379,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -3587,33 +3412,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3624,16 +3449,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3642,15 +3463,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -3659,31 +3480,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3701,17 +3518,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3732,7 +3549,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3740,7 +3557,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3749,36 +3566,30 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status @@ -3803,8 +3614,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -3814,34 +3625,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3850,7 +3655,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -3858,7 +3663,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -3869,17 +3674,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -3887,12 +3686,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -3904,17 +3703,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3923,53 +3716,48 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -3980,17 +3768,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -3998,12 +3780,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -4017,30 +3799,26 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StatusDetailProperties(msrest.serialization.Model): +class StatusDetailProperties(_serialization.Model): """The status detail properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4058,28 +3836,24 @@ class StatusDetailProperties(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'code': {'readonly': True}, - 'description': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'correlation_id': {'readonly': True}, + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StatusDetailProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.code = None self.description = None @@ -4087,15 +3861,15 @@ def __init__( self.correlation_id = None -class SyncProperties(msrest.serialization.Model): +class SyncProperties(_serialization.Model): """The sync properties of the connected registry with its parent. 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 token_id: Required. The resource ID of the ACR token used to authenticate the connected - registry to its parent during sync. + :ivar token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. :vartype token_id: str :ivar schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4103,8 +3877,9 @@ class SyncProperties(msrest.serialization.Model): :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :vartype sync_window: ~datetime.timedelta - :ivar message_ttl: Required. The period of time for which a message is available to sync before - it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :vartype message_ttl: ~datetime.timedelta :ivar last_sync_time: The last time a sync occurred between the connected registry and its parent. @@ -4115,19 +3890,19 @@ class SyncProperties(msrest.serialization.Model): """ _validation = { - 'token_id': {'required': True}, - 'message_ttl': {'required': True}, - 'last_sync_time': {'readonly': True}, - 'gateway_endpoint': {'readonly': True}, + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'gateway_endpoint': {'key': 'gatewayEndpoint', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, } def __init__( @@ -4140,8 +3915,8 @@ def __init__( **kwargs ): """ - :keyword token_id: Required. The resource ID of the ACR token used to authenticate the - connected registry to its parent during sync. + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. :paramtype token_id: str :keyword schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4149,12 +3924,12 @@ def __init__( :keyword sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype sync_window: ~datetime.timedelta - :keyword message_ttl: Required. The period of time for which a message is available to sync - before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per - ISO8601. + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.schedule = schedule self.sync_window = sync_window @@ -4163,7 +3938,7 @@ def __init__( self.gateway_endpoint = None -class SyncUpdateProperties(msrest.serialization.Model): +class SyncUpdateProperties(_serialization.Model): """The parameters for updating the sync properties of the connected registry with its parent. :ivar schedule: The cron expression indicating the schedule that the connected registry will @@ -4178,9 +3953,9 @@ class SyncUpdateProperties(msrest.serialization.Model): """ _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, } def __init__( @@ -4202,27 +3977,27 @@ def __init__( expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncUpdateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.sync_window = sync_window self.message_ttl = message_ttl -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -4230,44 +4005,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -4276,17 +4051,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -4300,15 +4075,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -4329,12 +4104,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -4346,7 +4121,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -4358,45 +4133,41 @@ def __init__( self.version = version -class TlsCertificateProperties(msrest.serialization.Model): +class TlsCertificateProperties(_serialization.Model): """The TLS certificate properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of certificate location. Possible values include: "LocalDirectory". + :ivar type: The type of certificate location. "LocalDirectory" :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.CertificateType :ivar location: Indicates the location of the certificates. :vartype location: str """ _validation = { - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsCertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.location = None -class TlsProperties(msrest.serialization.Model): +class TlsProperties(_serialization.Model): """The TLS properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Indicates whether HTTPS is enabled for the login server. Possible values include: - "Enabled", "Disabled". + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TlsStatus :ivar certificate: The certificate used to configure HTTPS for the login server. :vartype certificate: @@ -4404,22 +4175,18 @@ class TlsProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'certificate': {'readonly': True}, + "status": {"readonly": True}, + "certificate": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'TlsCertificateProperties'}, + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.certificate = None @@ -4439,8 +4206,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -4449,38 +4216,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -4490,11 +4257,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -4502,10 +4269,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -4518,23 +4285,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -4545,14 +4312,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar certificates: @@ -4564,15 +4331,15 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -4583,12 +4350,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -4599,17 +4366,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -4617,12 +4378,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4631,7 +4392,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPasswordName @@ -4640,14 +4401,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -4655,7 +4416,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -4663,26 +4424,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -4690,74 +4451,72 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -4767,64 +4526,56 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -4842,15 +4593,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4860,32 +4611,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4893,19 +4644,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4916,29 +4667,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4950,17 +4701,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -4970,23 +4721,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4997,7 +4748,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -5007,7 +4758,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -5018,17 +4769,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -5036,22 +4781,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -5063,12 +4808,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5077,20 +4822,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5101,7 +4846,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_connected_registries_operations.py index 9f8b20f27438..ca9b928805a7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_connected_registries_operations.py @@ -6,310 +6,330 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_deactivate_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ConnectedRegistriesOperations(object): - """ConnectedRegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -317,42 +337,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -363,16 +396,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -383,59 +414,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,72 +478,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -516,21 +653,25 @@ def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry 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 @@ -543,17 +684,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -562,93 +705,100 @@ def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -660,102 +810,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -763,21 +1022,26 @@ def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -790,17 +1054,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -809,93 +1075,100 @@ def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace - def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -907,42 +1180,50 @@ def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deactivate_initial( + raw_result = self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_export_pipelines_operations.py index 7ca90eff647a..9dbb760534fb 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_export_pipelines_operations.py @@ -6,251 +6,266 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +276,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +293,133 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,40 +427,88 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 @@ -439,17 +521,59 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -458,65 +582,74 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -526,25 +659,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -556,42 +686,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_import_pipelines_operations.py index bbf8f1b9005b..5119db016c37 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_import_pipelines_operations.py @@ -6,251 +6,266 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +276,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +293,133 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,40 +427,88 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 @@ -439,17 +521,59 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -458,65 +582,74 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -526,25 +659,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -556,42 +686,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_operations.py index 2aacd3bb2ad6..922034f4af3b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - accept = "application/json" +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: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_pipeline_runs_operations.py index b99c07daf204..5866182bed55 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_pipeline_runs_operations.py @@ -6,251 +6,266 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +276,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +293,133 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,18 +427,100 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -412,21 +528,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun 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 @@ -439,17 +559,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -458,65 +580,74 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -526,25 +657,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -556,42 +684,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_private_endpoint_connections_operations.py index d9e50984b54d..ac6bc54d50ee 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,251 +6,281 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +291,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +308,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,18 +442,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_08_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -412,22 +547,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_08_01_preview.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 :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 @@ -440,17 +579,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -459,65 +600,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -527,25 +677,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -557,42 +704,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_registries_operations.py index a9b4eabb16af..83b226674f93 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_registries_operations.py @@ -6,583 +6,556 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class RegistriesOperations(object): - """RegistriesOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') - - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -592,28 +565,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ImportImageParameters 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 @@ -624,145 +674,228 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -773,16 +906,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -792,55 +923,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -851,16 +992,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -870,106 +1009,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -977,36 +1132,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry 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 @@ -1018,17 +1246,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -1036,63 +1266,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1102,22 +1342,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -1129,80 +1365,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1210,37 +1470,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUpdateParameters 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 @@ -1252,17 +1590,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1270,141 +1610,163 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1415,16 +1777,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1434,174 +1794,275 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1610,34 +2071,114 @@ def _generate_credentials_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsParameters 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 @@ -1650,17 +2191,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1668,29 +2211,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_replications_operations.py index 9120bee9b77a..27c21103c81b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_replications_operations.py @@ -6,297 +6,307 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -307,16 +317,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,112 +334,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -439,18 +468,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -458,20 +568,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication 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 @@ -484,17 +598,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -503,65 +619,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -571,25 +696,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -601,83 +723,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,18 +831,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -704,21 +932,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ReplicationUpdateParameters 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 @@ -731,17 +963,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -750,29 +984,34 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_scope_maps_operations.py index 29abab990781..abe2a6e1d40d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_scope_maps_operations.py @@ -6,296 +6,307 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -306,16 +317,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -325,112 +334,131 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -438,18 +466,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -457,21 +565,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap 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 @@ -483,17 +595,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -502,65 +616,74 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -570,25 +693,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -600,83 +720,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -684,18 +828,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -703,21 +927,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMapUpdateParameters 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 @@ -729,17 +957,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -748,29 +978,34 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_tokens_operations.py index c8d186ad1d43..0daae78fe7ae 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_tokens_operations.py @@ -6,296 +6,307 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -306,16 +317,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -325,112 +334,131 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -438,18 +466,97 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -457,20 +564,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token + 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 @@ -482,17 +594,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -501,65 +615,74 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -569,25 +692,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -599,83 +719,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -683,18 +827,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -702,21 +926,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.TokenUpdateParameters 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 @@ -728,17 +956,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -747,29 +977,34 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_webhooks_operations.py index f8a2433c6c17..a73a45ede42c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_08_01_preview/operations/_webhooks_operations.py @@ -6,410 +6,421 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_08_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -420,16 +431,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,112 +448,131 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,18 +580,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -571,21 +679,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookCreateParameters 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 @@ -597,17 +709,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -616,65 +730,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -684,25 +807,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -714,83 +834,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -798,18 +942,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -817,21 +1041,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_08_01_preview.models.WebhookUpdateParameters 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 @@ -843,17 +1071,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -862,149 +1092,167 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_08_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-08-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1015,16 +1263,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1034,71 +1280,76 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_08_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-08-01-preview") # type: str + api_version: Literal["2021-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-08-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_configuration.py index 33527334045e..cc590c1caa16 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_container_registry_management_client.py index 5f5c5bdfc9b9..eabd350a2697 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_container_registry_management_client.py @@ -9,20 +9,26 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, WebhooksOperations +from .operations import ( + Operations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -37,9 +43,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2021_09_01.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_09_01.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,25 +63,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -84,7 +89,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 @@ -97,15 +102,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_metadata.json index ed816632072d..4b6907258b4f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -103,4 +103,4 @@ "replications": "ReplicationsOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_configuration.py index 519236a71f16..58fef133eea9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_container_registry_management_client.py index c757a408f408..5ad10f92dd3f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_container_registry_management_client.py @@ -9,20 +9,26 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, WebhooksOperations +from .operations import ( + Operations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword """ContainerRegistryManagementClient. :ivar registries: RegistriesOperations operations @@ -38,9 +44,9 @@ class ContainerRegistryManagementClient: azure.mgmt.containerregistry.v2021_09_01.aio.operations.ReplicationsOperations :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_09_01.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -58,25 +64,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -85,7 +90,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/__init__.py index ac77adfaf7af..da4da531636b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_operations.py index 7a12e69126bc..b0f00c73e7c6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_operations.py @@ -6,79 +6,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +115,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +132,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py index eb8265578dd5..d5a1d8797e55 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,96 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +151,129 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +281,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_09_01.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -257,22 +386,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_09_01.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 :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 @@ -285,17 +418,17 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -304,65 +437,72 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,25 +512,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -402,42 +539,48 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_registries_operations.py index 91e31efc09f0..50083fd437be 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_registries_operations.py @@ -6,82 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_private_link_resource_request, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_private_link_resource_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,27 +132,103 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters 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 @@ -122,145 +239,222 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -271,16 +465,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -290,55 +482,63 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -349,16 +549,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -368,106 +566,118 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -475,36 +685,42 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry + :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 @@ -517,17 +733,86 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -535,63 +820,71 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -601,22 +894,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -628,80 +917,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -709,37 +1018,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters 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 @@ -752,17 +1141,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -770,141 +1159,159 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -915,16 +1322,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -934,59 +1339,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace_async async def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2021_09_01.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -994,139 +1401,221 @@ async def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_replications_operations.py index a928e13b2da2..461ba988d7da 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_replications_operations.py @@ -6,96 +6,122 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +132,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +149,129 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +279,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -257,20 +379,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication 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 @@ -283,17 +409,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +428,72 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +503,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -400,83 +530,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +634,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +735,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters 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 @@ -530,17 +766,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,29 +785,34 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_webhooks_operations.py index d3b7d2b9ae8a..867b0e3c7b02 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_webhooks_operations.py @@ -6,95 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +152,129 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +282,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,21 +383,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters 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 @@ -283,17 +414,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +433,72 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +508,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -400,83 +535,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +639,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +740,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters 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 @@ -530,17 +771,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,149 +790,165 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -702,16 +959,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,71 +976,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/__init__.py index 64fdecc3cc0e..4cbf35059285 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/__init__.py @@ -71,117 +71,119 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - NetworkRuleBypassOptions, - PasswordName, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Actor', - 'CallbackConfig', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPolicy', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'PackageType', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'Sku', - 'Source', - 'Status', - 'StorageAccountProperties', - 'SystemData', - 'Target', - 'TrustPolicy', - 'UserIdentityProperties', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ExportPolicyStatus', - 'ImportMode', - 'LastModifiedByType', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "Actor", + "CallbackConfig", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPolicy", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "PackageType", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "Sku", + "Source", + "Status", + "StorageAccountProperties", + "SystemData", + "Target", + "TrustPolicy", + "UserIdentityProperties", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "NetworkRuleBypassOptions", + "PasswordName", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_container_registry_management_client_enums.py index 6de31ca4a221..2d4f90e5beae 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_container_registry_management_client_enums.py @@ -7,63 +7,62 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of IP ACL rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of IP ACL rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ExportPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -71,39 +70,39 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of private endpoint connection resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of private endpoint connection resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -112,54 +111,56 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -167,16 +168,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_models_py3.py index fd4e51dad753..96c2adac29b4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/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. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -24,67 +26,56 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. :vartype key_vault_properties: @@ -92,31 +83,31 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2021_09_01.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -124,31 +115,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2021_09_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -158,15 +144,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -175,13 +161,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -190,14 +176,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2021_09_01.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -205,20 +191,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -236,17 +217,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -259,12 +240,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2021_09_01.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -286,25 +267,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -325,7 +306,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2021_09_01.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -335,7 +316,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -346,17 +327,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -364,12 +339,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -385,17 +360,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -414,7 +389,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -422,7 +397,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -438,11 +413,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -467,7 +442,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -475,42 +450,37 @@ def __init__( self.version = version -class ExportPolicy(msrest.serialization.Model): +class ExportPolicy(_serialization.Model): """The export policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ExportPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "ExportPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ExportPolicyStatus """ - super(ExportPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity @@ -522,10 +492,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -533,8 +503,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -542,8 +512,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity @@ -553,19 +523,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2021_09_01.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -574,33 +544,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -609,18 +579,18 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories self.mode = mode -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -631,22 +601,22 @@ class ImportSource(msrest.serialization.Model): :vartype registry_uri: str :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -655,7 +625,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -666,146 +636,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". Default value: - "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_09_01.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = "Allow", - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Union[str, "_models.Action"] = "Allow", **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". Default value: - "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_09_01.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -824,33 +773,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -858,48 +801,48 @@ def __init__( self.last_key_rotation_timestamp = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2021_09_01.models.DefaultAction :ivar ip_rules: The IP ACL rules. :vartype ip_rules: list[~azure.mgmt.containerregistry.v2021_09_01.models.IPRule] """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2021_09_01.models.DefaultAction :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_09_01.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -918,11 +861,14 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -930,9 +876,9 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -950,7 +896,7 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2021_09_01.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display @@ -958,7 +904,7 @@ def __init__( self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -972,10 +918,10 @@ class OperationDisplayDefinition(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__( @@ -997,14 +943,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1016,16 +962,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1035,12 +977,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1052,9 +994,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1073,13 +1015,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1097,12 +1039,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1130,7 +1072,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1139,7 +1081,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1151,15 +1093,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -1170,12 +1112,12 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2021_09_01.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class PackageType(msrest.serialization.Model): +class PackageType(_serialization.Model): """The properties of a package type. Variables are only populated by the server, and will be ignored when sending a request. @@ -1187,30 +1129,25 @@ class PackageType(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of the package type. :paramtype name: str """ - super(PackageType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.endpoint = None -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -1224,19 +1161,19 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - 'export_policy': {'key': 'exportPolicy', 'type': 'ExportPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, - export_policy: Optional["ExportPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, **kwargs ): """ @@ -1249,14 +1186,14 @@ def __init__( :keyword export_policy: The export policy for a container registry. :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.ExportPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy self.export_policy = export_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -1264,25 +1201,20 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -1298,26 +1230,22 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1343,35 +1271,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -1382,13 +1313,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_09_01.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -1401,14 +1332,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1421,12 +1352,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -1446,22 +1377,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -1480,7 +1411,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -1489,7 +1420,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -1500,16 +1431,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -1519,119 +1446,109 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1644,47 +1561,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_09_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1693,7 +1604,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1706,14 +1617,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_09_01.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2021_09_01.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_09_01.models.IdentityProperties @@ -1722,8 +1633,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -1746,83 +1657,86 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_09_01.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2021_09_01.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2021_09_01.models.IdentityProperties @@ -1837,19 +1751,19 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_09_01.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ZoneRedundancy """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -1868,7 +1782,7 @@ def __init__( self.zone_redundancy = zone_redundancy -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -1878,16 +1792,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1895,12 +1805,12 @@ def __init__( :keyword passwords: The list of passwords for a container registry. :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -1911,17 +1821,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -1929,53 +1833,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -1988,9 +1887,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -2010,50 +1909,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_09_01.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2021_09_01.models.Sku @@ -2068,47 +1963,47 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_09_01.models.NetworkRuleBypassOptions """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, **kwargs ): """ :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2021_09_01.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2021_09_01.models.Sku @@ -2123,15 +2018,15 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_09_01.models.NetworkRuleBypassOptions """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -2144,24 +2039,24 @@ def __init__( self.network_rule_bypass_options = network_rule_bypass_options -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -2170,27 +2065,27 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -2198,20 +2093,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -2228,15 +2118,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_09_01.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ProvisioningState @@ -2247,32 +2137,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -2280,33 +2170,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -2317,16 +2207,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -2335,15 +2221,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -2352,31 +2238,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -2394,17 +2276,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -2425,7 +2307,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -2433,7 +2315,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2442,83 +2324,72 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2021_09_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_09_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -2529,17 +2400,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -2547,12 +2412,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -2566,74 +2431,65 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StorageAccountProperties(msrest.serialization.Model): +class StorageAccountProperties(_serialization.Model): """The properties of a storage account for a container registry. Only applicable to Classic SKU. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The resource ID of the storage account. + :ivar id: The resource ID of the storage account. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. The resource ID of the storage account. + :keyword id: The resource ID of the storage account. Required. :paramtype id: str """ - super(StorageAccountProperties, 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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2021_09_01.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -2641,44 +2497,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2021_09_01.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -2687,17 +2543,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -2711,15 +2567,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -2740,12 +2596,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -2757,7 +2613,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -2769,43 +2625,41 @@ def __init__( self.version = version -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_09_01.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -2815,24 +2669,18 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id @@ -2850,15 +2698,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_09_01.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -2867,32 +2715,32 @@ class Webhook(Resource): :ivar actions: The list of actions that trigger the webhook to post notifications. :vartype actions: list[str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_09_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2900,19 +2748,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2921,29 +2769,29 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -2954,17 +2802,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -2974,23 +2822,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -2999,7 +2847,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -3009,7 +2857,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -3020,17 +2868,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -3038,22 +2880,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -3064,12 +2906,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -3078,20 +2920,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' @@ -3100,7 +2942,7 @@ def __init__( :keyword actions: The list of actions that trigger the webhook to post notifications. :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/__init__.py index ac77adfaf7af..da4da531636b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/__init__.py @@ -12,10 +12,16 @@ from ._replications_operations import ReplicationsOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'RegistriesOperations', - 'Operations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'WebhooksOperations', + "RegistriesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_operations.py index 0147e8507765..14ce5e53a19d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_operations.py @@ -6,108 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - accept = "application/json" +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: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +137,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_private_endpoint_connections_operations.py index f137dc65e3de..418b2f6118b3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_private_endpoint_connections_operations.py @@ -6,251 +6,271 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +281,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +298,129 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,18 +428,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_09_01.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -412,22 +533,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_09_01.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 :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 @@ -440,17 +565,17 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -459,65 +584,72 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -527,25 +659,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -557,42 +686,48 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_registries_operations.py index 6e8ef9c69864..8045777e3218 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_registries_operations.py @@ -6,577 +6,526 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_link_resource_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 RegistriesOperations(object): - """RegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -586,27 +535,103 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. - :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters 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 @@ -617,145 +642,221 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -766,16 +867,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -785,55 +884,62 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -844,16 +950,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -863,106 +967,118 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -970,36 +1086,42 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry + :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 @@ -1011,17 +1133,84 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -1029,63 +1218,71 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1095,22 +1292,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -1122,80 +1315,100 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1203,37 +1416,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters 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 @@ -1245,17 +1536,17 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1263,141 +1554,159 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1408,16 +1717,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1427,59 +1734,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2021_09_01.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1487,139 +1796,221 @@ def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_replications_operations.py index 89922d33b3d1..d19527c10877 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_replications_operations.py @@ -6,297 +6,295 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_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, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class ReplicationsOperations(object): - """ReplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -307,16 +305,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,112 +322,129 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -439,18 +452,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -458,20 +552,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication 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 @@ -484,17 +582,17 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -503,65 +601,72 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -571,25 +676,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -601,83 +703,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,18 +807,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -704,21 +908,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters 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 @@ -731,17 +939,17 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -750,29 +958,34 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_webhooks_operations.py index ed9ba9394bc5..37ca0b5b01f9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_webhooks_operations.py @@ -6,410 +6,402 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = 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_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_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, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['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=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WebhooksOperations(object): - """WebhooksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_09_01.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -420,16 +412,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,112 +429,127 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,18 +557,96 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -571,21 +654,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters 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 @@ -596,17 +683,17 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -615,65 +702,72 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -683,25 +777,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -713,83 +804,103 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -797,18 +908,96 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -816,21 +1005,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters 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 @@ -841,17 +1034,17 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_09_01.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -860,149 +1053,162 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_09_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1013,16 +1219,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1032,71 +1236,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_configuration.py index fc9bacc047d3..7ae9e56e33f8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_container_registry_management_client.py index 8a8b2c58043e..0b09586afcfb 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -56,9 +68,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_12_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,31 +88,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -109,7 +126,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 @@ -122,15 +139,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_metadata.json index d8dbf3226c53..01c5b874787b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "tokens": "TokensOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_configuration.py index 170a3e9473c8..b1b8d76ecd7d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_container_registry_management_client.py index c8a5d3cab43a..a378e6670afa 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -57,9 +69,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -77,31 +89,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -110,7 +127,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_connected_registries_operations.py index 71f3cec01b0f..108daea63dad 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_connected_registries_operations.py @@ -6,61 +6,77 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._connected_registries_operations import build_create_request_initial, build_deactivate_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConnectedRegistriesOperations: - """ConnectedRegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -68,42 +84,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -114,16 +143,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,59 +161,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,72 +225,174 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -267,21 +400,25 @@ async def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry 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 @@ -294,17 +431,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -313,93 +452,100 @@ async def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -411,102 +557,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -514,21 +769,26 @@ async def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -541,17 +801,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -560,93 +822,100 @@ async def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace_async - async def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -658,42 +927,50 @@ async def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deactivate_initial( + raw_result = await self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_export_pipelines_operations.py index 7254e4891737..bd5f96cd5654 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +153,63 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,94 +217,119 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline + :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 @@ -286,17 +342,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +444,100 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -403,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_import_pipelines_operations.py index 6be807a7b09c..20a39cfb4a0e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +153,63 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,94 +217,119 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline + :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 @@ -286,17 +342,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +444,100 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -403,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_operations.py index b9a3b6e7838a..e8b96bf23525 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_pipeline_runs_operations.py index e07dbbb7858a..e476fae828bf 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,96 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +151,63 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,72 +215,172 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -259,21 +388,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun 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 @@ -286,17 +419,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +440,100 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -403,42 +545,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_private_endpoint_connections_operations.py index f5c93d7c2046..56900c741f2f 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,96 +6,126 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +136,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +153,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +287,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_12_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -257,22 +392,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_12_01_preview.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 :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 @@ -285,17 +424,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -304,65 +445,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,25 +522,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -402,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_registries_operations.py index d0b8e9de74c8..27c649d79714 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,126 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_generate_credentials_request_initial, build_get_private_link_resource_request, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_private_link_resource_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +135,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters 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 @@ -123,145 +244,228 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -272,16 +476,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -291,55 +493,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -350,16 +562,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -369,106 +579,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -476,36 +702,79 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 @@ -518,17 +787,51 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -536,63 +839,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -602,22 +915,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -629,80 +938,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -710,37 +1043,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters 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 @@ -753,17 +1166,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -771,141 +1186,163 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -916,16 +1353,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -935,59 +1370,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace_async async def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2021_12_01_preview.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -995,214 +1434,397 @@ async def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters 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 @@ -1215,17 +1837,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1233,29 +1857,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_replications_operations.py index 7f6b91ec8132..58f43f165791 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_replications_operations.py @@ -6,96 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +151,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +285,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -257,20 +385,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication 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 @@ -283,17 +415,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +436,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +513,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -400,83 +540,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +648,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +749,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters 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 @@ -530,17 +780,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,29 +801,34 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_scope_maps_operations.py index 2b9d1cc3fed9..e8714dc75693 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_scope_maps_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,59 +152,63 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,72 +216,172 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -258,21 +389,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap 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 @@ -285,17 +420,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -304,93 +441,100 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -402,102 +546,209 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -505,21 +756,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters 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 @@ -532,17 +787,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -551,29 +808,34 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_tokens_operations.py index e8ffc102d23b..cd37971ff762 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_tokens_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,59 +152,61 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,72 +214,169 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -258,20 +384,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token + 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 @@ -283,17 +414,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,93 +435,100 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -400,102 +540,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +748,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters 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 @@ -529,17 +778,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -548,29 +799,34 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_webhooks_operations.py index b013aad2ae10..4fd7533a4334 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_webhooks_operations.py @@ -6,95 +6,127 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +154,133 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +288,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,21 +389,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters 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 @@ -283,17 +420,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +441,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +518,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -400,83 +545,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +653,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +754,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters 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 @@ -530,17 +785,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,149 +806,169 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -702,16 +979,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,71 +996,76 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/__init__.py index 51c980de1cff..28e358371de5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/__init__.py @@ -111,187 +111,189 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActivationProperties', - 'ActiveDirectoryObject', - 'Actor', - 'CallbackConfig', - 'ConnectedRegistry', - 'ConnectedRegistryListResult', - 'ConnectedRegistryUpdateParameters', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'ExportPolicy', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'LoggingProperties', - 'LoginServerProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'ParentProperties', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'Sku', - 'Source', - 'Status', - 'StatusDetailProperties', - 'SyncProperties', - 'SyncUpdateProperties', - 'SystemData', - 'Target', - 'TlsCertificateProperties', - 'TlsProperties', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'TrustPolicy', - 'UserIdentityProperties', - 'VirtualNetworkRule', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ActivationStatus', - 'AuditLogStatus', - 'CertificateType', - 'ConnectedRegistryMode', - 'ConnectionState', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ExportPolicyStatus', - 'ImportMode', - 'LastModifiedByType', - 'LogLevel', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TlsStatus', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "Source", + "Status", + "StatusDetailProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "VirtualNetworkRule", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_container_registry_management_client_enums.py index 0c0448c6db6f..51a3b9c4423a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_container_registry_management_client_enums.py @@ -7,101 +7,100 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of virtual network rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of virtual network rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ActivationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The activation status of the connected registry. - """ + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" ACTIVE = "Active" INACTIVE = "Inactive" -class AuditLogStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether audit logs are enabled on the connected registry. - """ + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class CertificateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of certificate location. - """ + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" LOCAL_DIRECTORY = "LocalDirectory" -class ConnectedRegistryMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The mode of the connected registry resource that indicates the permissions of the registry. - """ + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" READ_WRITE = "ReadWrite" READ_ONLY = "ReadOnly" REGISTRY = "Registry" MIRROR = "Mirror" -class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current connection state of the connected registry. - """ + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" ONLINE = "Online" OFFLINE = "Offline" SYNCING = "Syncing" UNHEALTHY = "Unhealthy" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ExportPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -109,18 +108,18 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity of logs persisted on the connected registry. - """ + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" DEBUG = "Debug" INFORMATION = "Information" @@ -128,55 +127,57 @@ class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" NONE = "None" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -185,87 +186,91 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TlsStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether HTTPS is enabled for the login server. - """ + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -273,16 +278,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_models_py3.py index 9e082fd2b935..26cadc8d8944 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/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. @@ -7,44 +8,41 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActivationProperties(msrest.serialization.Model): +class ActivationProperties(_serialization.Model): """The activation properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The activation status of the connected registry. Possible values include: - "Active", "Inactive". + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ActivationStatus """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ActivationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -56,17 +54,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -75,12 +67,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -89,63 +81,52 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -161,33 +142,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ConnectedRegistry(ProxyResource): +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes """An object that represents a connected registry for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -200,18 +177,18 @@ class ConnectedRegistry(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState :ivar mode: The mode of the connected registry resource that indicates the permissions of the - registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryMode :ivar version: The current version of ACR runtime on the connected registry. :vartype version: str - :ivar connection_state: The current connection state of the connected registry. Possible values - include: "Online", "Offline", "Syncing", "Unhealthy". + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". :vartype connection_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectionState :ivar last_activity_time: The last activity time of the connected registry. @@ -238,51 +215,51 @@ class ConnectedRegistry(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'connection_state': {'readonly': True}, - 'last_activity_time': {'readonly': True}, - 'activation': {'readonly': True}, - 'status_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'connection_state': {'key': 'properties.connectionState', 'type': 'str'}, - 'last_activity_time': {'key': 'properties.lastActivityTime', 'type': 'iso-8601'}, - 'activation': {'key': 'properties.activation', 'type': 'ActivationProperties'}, - 'parent': {'key': 'properties.parent', 'type': 'ParentProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'LoginServerProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'status_details': {'key': 'properties.statusDetails', 'type': '[StatusDetailProperties]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - mode: Optional[Union[str, "ConnectedRegistryMode"]] = None, - parent: Optional["ParentProperties"] = None, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, client_token_ids: Optional[List[str]] = None, - login_server: Optional["LoginServerProperties"] = None, - logging: Optional["LoggingProperties"] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, notifications_list: Optional[List[str]] = None, **kwargs ): """ :keyword mode: The mode of the connected registry resource that indicates the permissions of - the registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + the registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryMode :keyword parent: The parent of the connected registry. @@ -299,7 +276,7 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistry, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.mode = mode self.version = None @@ -314,7 +291,7 @@ def __init__( self.notifications_list = notifications_list -class ConnectedRegistryListResult(msrest.serialization.Model): +class ConnectedRegistryListResult(_serialization.Model): """The result of a request to list connected registries for a container registry. :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink @@ -326,16 +303,12 @@ class ConnectedRegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectedRegistry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ConnectedRegistry"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of connected registries. Since this list may be incomplete, the @@ -345,12 +318,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of connected registries. :paramtype next_link: str """ - super(ConnectedRegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConnectedRegistryUpdateParameters(msrest.serialization.Model): +class ConnectedRegistryUpdateParameters(_serialization.Model): """The parameters for updating a connected registry. :ivar sync_properties: The sync properties of the connected registry with its parent. @@ -367,17 +340,17 @@ class ConnectedRegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sync_properties': {'key': 'properties.syncProperties', 'type': 'SyncUpdateProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - sync_properties: Optional["SyncUpdateProperties"] = None, - logging: Optional["LoggingProperties"] = None, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, client_token_ids: Optional[List[str]] = None, notifications_list: Optional[List[str]] = None, **kwargs @@ -395,18 +368,18 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sync_properties = sync_properties self.logging = logging self.client_token_ids = client_token_ids self.notifications_list = notifications_list -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -415,32 +388,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -448,31 +421,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -483,15 +451,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -500,13 +468,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -515,14 +483,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -530,20 +498,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -561,17 +524,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -584,12 +547,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -611,25 +574,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -650,7 +613,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -660,7 +623,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -671,17 +634,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -689,12 +646,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -710,17 +667,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -739,7 +696,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -747,7 +704,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -763,11 +720,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -792,7 +749,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -824,39 +781,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -872,7 +829,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -880,7 +837,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -891,16 +848,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -909,12 +862,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -925,29 +878,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -955,46 +901,41 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ExportPolicy(msrest.serialization.Model): +class ExportPolicy(_serialization.Model): """The export policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "ExportPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPolicyStatus """ - super(ExportPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -1003,15 +944,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1019,7 +960,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -1029,17 +970,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -1050,16 +991,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1068,20 +1005,20 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1094,10 +1031,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1105,8 +1042,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1114,8 +1051,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1126,19 +1063,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2021_12_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1147,33 +1084,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1182,11 +1119,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -1220,41 +1157,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -1273,7 +1210,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -1282,7 +1219,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1293,16 +1230,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1311,67 +1244,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -1383,22 +1314,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -1407,7 +1338,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -1418,144 +1349,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1574,33 +1486,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1608,45 +1514,45 @@ def __init__( self.last_key_rotation_timestamp = None -class LoggingProperties(msrest.serialization.Model): +class LoggingProperties(_serialization.Model): """The logging properties of the connected registry. - :ivar log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". :vartype log_level: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.LogLevel :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :vartype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.AuditLogStatus """ _attribute_map = { - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'audit_log_status': {'key': 'auditLogStatus', 'type': 'str'}, + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, } def __init__( self, *, - log_level: Optional[Union[str, "LogLevel"]] = "Information", - audit_log_status: Optional[Union[str, "AuditLogStatus"]] = "Disabled", + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", **kwargs ): """ - :keyword log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". :paramtype log_level: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.LogLevel :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :paramtype audit_log_status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.AuditLogStatus """ - super(LoggingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_level = log_level self.audit_log_status = audit_log_status -class LoginServerProperties(msrest.serialization.Model): +class LoginServerProperties(_serialization.Model): """The login server properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1658,33 +1564,29 @@ class LoginServerProperties(msrest.serialization.Model): """ _validation = { - 'host': {'readonly': True}, - 'tls': {'readonly': True}, + "host": {"readonly": True}, + "tls": {"readonly": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'tls': {'key': 'tls', 'type': 'TlsProperties'}, + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LoginServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.host = None self.tls = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.DefaultAction :ivar virtual_network_rules: The virtual network rules. @@ -1695,26 +1597,26 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.DefaultAction :keyword virtual_network_rules: The virtual network rules. @@ -1723,13 +1625,13 @@ def __init__( :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1749,11 +1651,14 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1761,9 +1666,9 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1782,7 +1687,7 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display @@ -1790,7 +1695,7 @@ def __init__( self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1804,10 +1709,10 @@ class OperationDisplayDefinition(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__( @@ -1829,14 +1734,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1849,16 +1754,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1869,12 +1770,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1886,9 +1787,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1907,13 +1808,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1931,12 +1832,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1964,7 +1865,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1973,7 +1874,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -1985,15 +1886,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -2004,48 +1905,48 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class ParentProperties(msrest.serialization.Model): +class ParentProperties(_serialization.Model): """The properties of the connected registry parent. All required parameters must be populated in order to send to Azure. :ivar id: The resource ID of the parent to which the connected registry will be associated. :vartype id: str - :ivar sync_properties: Required. The sync properties of the connected registry with its parent. + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. :vartype sync_properties: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SyncProperties """ _validation = { - 'sync_properties': {'required': True}, + "sync_properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'sync_properties': {'key': 'syncProperties', 'type': 'SyncProperties'}, + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, } def __init__( self, *, - sync_properties: "SyncProperties", - id: Optional[str] = None, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: The resource ID of the parent to which the connected registry will be associated. :paramtype id: str - :keyword sync_properties: Required. The sync properties of the connected registry with its - parent. + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. :paramtype sync_properties: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SyncProperties """ - super(ParentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.sync_properties = sync_properties @@ -2063,8 +1964,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -2077,29 +1978,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -2110,14 +2011,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -2128,16 +2029,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -2146,12 +2043,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -2172,11 +2069,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -2184,8 +2081,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -2206,7 +2103,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -2214,7 +2111,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -2244,16 +2141,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -2261,13 +2158,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -2298,7 +2195,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -2311,11 +2208,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -2323,35 +2219,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -2359,31 +2253,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -2391,58 +2284,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -2451,25 +2334,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -2478,25 +2356,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -2512,19 +2385,19 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - 'export_policy': {'key': 'exportPolicy', 'type': 'ExportPolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, - export_policy: Optional["ExportPolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, **kwargs ): """ @@ -2539,14 +2412,14 @@ def __init__( :keyword export_policy: The export policy for a container registry. :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy self.export_policy = export_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -2554,21 +2427,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -2592,35 +2460,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2632,13 +2503,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2021_12_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2651,14 +2522,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2671,12 +2542,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2696,22 +2567,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2730,7 +2601,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2739,7 +2610,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2751,16 +2622,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2771,61 +2638,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2833,84 +2700,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2923,47 +2775,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2972,7 +2818,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -2985,14 +2831,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.IdentityProperties @@ -3001,8 +2847,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -3027,15 +2873,15 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ZoneRedundancy :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3043,71 +2889,74 @@ class Registry(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, - anonymous_pull_enabled: Optional[bool] = False, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -3125,21 +2974,21 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ZoneRedundancy :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -3159,7 +3008,7 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -3170,16 +3019,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -3188,12 +3033,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -3204,17 +3049,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -3222,53 +3061,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -3281,9 +3115,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -3303,50 +3137,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Sku @@ -3363,11 +3193,11 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.NetworkRuleBypassOptions :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. @@ -3375,32 +3205,32 @@ class RegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, anonymous_pull_enabled: Optional[bool] = None, **kwargs ): @@ -3408,7 +3238,7 @@ def __init__( :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Sku @@ -3425,17 +3255,17 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.NetworkRuleBypassOptions :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. :paramtype anonymous_pull_enabled: bool """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -3449,25 +3279,25 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -3476,28 +3306,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -3505,20 +3335,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3535,15 +3360,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState @@ -3554,32 +3379,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -3587,33 +3412,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3624,16 +3449,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3642,15 +3463,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -3659,31 +3480,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3701,17 +3518,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3732,7 +3549,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3740,7 +3557,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3749,36 +3566,30 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status @@ -3803,8 +3614,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -3814,34 +3625,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3850,7 +3655,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -3858,7 +3663,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -3869,17 +3674,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -3887,12 +3686,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -3904,17 +3703,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3923,53 +3716,48 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -3980,17 +3768,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -3998,12 +3780,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -4017,30 +3799,26 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StatusDetailProperties(msrest.serialization.Model): +class StatusDetailProperties(_serialization.Model): """The status detail properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4058,28 +3836,24 @@ class StatusDetailProperties(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'code': {'readonly': True}, - 'description': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'correlation_id': {'readonly': True}, + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StatusDetailProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.code = None self.description = None @@ -4087,15 +3861,15 @@ def __init__( self.correlation_id = None -class SyncProperties(msrest.serialization.Model): +class SyncProperties(_serialization.Model): """The sync properties of the connected registry with its parent. 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 token_id: Required. The resource ID of the ACR token used to authenticate the connected - registry to its parent during sync. + :ivar token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. :vartype token_id: str :ivar schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4103,8 +3877,9 @@ class SyncProperties(msrest.serialization.Model): :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :vartype sync_window: ~datetime.timedelta - :ivar message_ttl: Required. The period of time for which a message is available to sync before - it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :vartype message_ttl: ~datetime.timedelta :ivar last_sync_time: The last time a sync occurred between the connected registry and its parent. @@ -4115,19 +3890,19 @@ class SyncProperties(msrest.serialization.Model): """ _validation = { - 'token_id': {'required': True}, - 'message_ttl': {'required': True}, - 'last_sync_time': {'readonly': True}, - 'gateway_endpoint': {'readonly': True}, + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'gateway_endpoint': {'key': 'gatewayEndpoint', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, } def __init__( @@ -4140,8 +3915,8 @@ def __init__( **kwargs ): """ - :keyword token_id: Required. The resource ID of the ACR token used to authenticate the - connected registry to its parent during sync. + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. :paramtype token_id: str :keyword schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4149,12 +3924,12 @@ def __init__( :keyword sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype sync_window: ~datetime.timedelta - :keyword message_ttl: Required. The period of time for which a message is available to sync - before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per - ISO8601. + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.schedule = schedule self.sync_window = sync_window @@ -4163,7 +3938,7 @@ def __init__( self.gateway_endpoint = None -class SyncUpdateProperties(msrest.serialization.Model): +class SyncUpdateProperties(_serialization.Model): """The parameters for updating the sync properties of the connected registry with its parent. :ivar schedule: The cron expression indicating the schedule that the connected registry will @@ -4178,9 +3953,9 @@ class SyncUpdateProperties(msrest.serialization.Model): """ _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, } def __init__( @@ -4202,27 +3977,27 @@ def __init__( expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncUpdateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.sync_window = sync_window self.message_ttl = message_ttl -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -4230,44 +4005,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -4276,17 +4051,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -4300,15 +4075,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -4329,12 +4104,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -4346,7 +4121,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -4358,45 +4133,41 @@ def __init__( self.version = version -class TlsCertificateProperties(msrest.serialization.Model): +class TlsCertificateProperties(_serialization.Model): """The TLS certificate properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of certificate location. Possible values include: "LocalDirectory". + :ivar type: The type of certificate location. "LocalDirectory" :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.CertificateType :ivar location: Indicates the location of the certificates. :vartype location: str """ _validation = { - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsCertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.location = None -class TlsProperties(msrest.serialization.Model): +class TlsProperties(_serialization.Model): """The TLS properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Indicates whether HTTPS is enabled for the login server. Possible values include: - "Enabled", "Disabled". + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TlsStatus :ivar certificate: The certificate used to configure HTTPS for the login server. :vartype certificate: @@ -4404,22 +4175,18 @@ class TlsProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'certificate': {'readonly': True}, + "status": {"readonly": True}, + "certificate": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'TlsCertificateProperties'}, + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.certificate = None @@ -4439,8 +4206,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -4449,38 +4216,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -4490,11 +4257,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -4502,10 +4269,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -4518,23 +4285,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -4545,14 +4312,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar certificates: @@ -4564,15 +4331,15 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -4583,12 +4350,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -4599,17 +4366,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -4617,12 +4378,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4631,7 +4392,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPasswordName @@ -4640,14 +4401,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -4655,7 +4416,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -4663,26 +4424,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -4690,74 +4451,72 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -4767,64 +4526,56 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual network rule. All required parameters must be populated in order to send to Azure. - :ivar action: The action of virtual network rule. Possible values include: "Allow". + :ivar action: The action of virtual network rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Action - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, } def __init__( - self, - *, - virtual_network_resource_id: str, - action: Optional[Union[str, "Action"]] = None, - **kwargs + self, *, virtual_network_resource_id: str, action: Optional[Union[str, "_models.Action"]] = None, **kwargs ): """ - :keyword action: The action of virtual network rule. Possible values include: "Allow". + :keyword action: The action of virtual network rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Action - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.virtual_network_resource_id = virtual_network_resource_id @@ -4842,15 +4593,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4860,32 +4611,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4893,19 +4644,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4916,29 +4667,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4950,17 +4701,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -4970,23 +4721,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -4997,7 +4748,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -5007,7 +4758,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -5018,17 +4769,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -5036,22 +4781,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -5063,12 +4808,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5077,20 +4822,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5101,7 +4846,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_connected_registries_operations.py index af01022ae811..20c0e9708931 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_connected_registries_operations.py @@ -6,310 +6,330 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_deactivate_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ConnectedRegistriesOperations(object): - """ConnectedRegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -317,42 +337,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -363,16 +396,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -383,59 +414,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,72 +478,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -516,21 +653,25 @@ def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry 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 @@ -543,17 +684,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -562,93 +705,100 @@ def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -660,102 +810,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -763,21 +1022,26 @@ def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -790,17 +1054,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -809,93 +1075,100 @@ def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace - def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -907,42 +1180,50 @@ def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deactivate_initial( + raw_result = self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_export_pipelines_operations.py index 109e2fab0ccf..9908eaa7a0b5 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_export_pipelines_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,94 +364,119 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline + :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 @@ -447,17 +489,100 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +591,100 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -564,42 +696,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_import_pipelines_operations.py index cd04000fd8ee..06b680b22e97 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_import_pipelines_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,94 +364,119 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline + :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 @@ -447,17 +489,100 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +591,100 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -564,42 +696,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_operations.py index 995ce768f6f1..bc982faa4618 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +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: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_pipeline_runs_operations.py index 29c5e901ce43..e7e2591fb4bf 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_pipeline_runs_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,72 +364,172 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -420,21 +537,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun 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 @@ -447,17 +568,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +589,100 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -564,42 +694,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_private_endpoint_connections_operations.py index d4c457282a1c..c73ab3a38900 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,251 +6,281 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +291,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +308,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,18 +442,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2021_12_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -412,22 +547,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2021_12_01_preview.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 :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 @@ -440,17 +579,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -459,65 +600,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -527,25 +677,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -557,42 +704,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_registries_operations.py index ed462461a267..88dfea2d671a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_registries_operations.py @@ -6,621 +6,592 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_link_resource_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 RegistriesOperations(object): - """RegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -630,28 +601,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters 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 @@ -662,145 +710,228 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -811,16 +942,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,55 +959,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -889,16 +1028,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -908,106 +1045,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1015,36 +1168,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry 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 @@ -1056,17 +1282,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -1074,63 +1302,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1140,22 +1378,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -1167,80 +1401,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1248,37 +1506,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters 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 @@ -1290,17 +1626,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1308,141 +1646,163 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1453,16 +1813,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1472,59 +1830,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2021_12_01_preview.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1532,214 +1894,397 @@ def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters 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 @@ -1752,17 +2297,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1770,29 +2317,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_replications_operations.py index d4af74b8058d..d562ba6b4dc9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_replications_operations.py @@ -6,297 +6,307 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -307,16 +317,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,112 +334,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -439,18 +468,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -458,20 +568,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication 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 @@ -484,17 +598,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -503,65 +619,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -571,25 +696,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -601,83 +723,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,18 +831,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -704,21 +932,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters 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 @@ -731,17 +963,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -750,29 +984,34 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_scope_maps_operations.py index b37d6fe81a36..e3506188ae22 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_scope_maps_operations.py @@ -6,302 +6,313 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -312,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,59 +341,61 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,72 +403,170 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -465,21 +574,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap 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 @@ -491,17 +604,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -510,93 +625,100 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -608,102 +730,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -711,21 +938,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters 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 @@ -737,17 +968,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -756,29 +989,34 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_tokens_operations.py index 07b2fc00c78b..b2528f34819b 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_tokens_operations.py @@ -6,302 +6,313 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -312,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,59 +341,61 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,72 +403,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -465,20 +573,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token + 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 @@ -490,17 +603,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -509,93 +624,100 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -607,102 +729,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -710,21 +937,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters 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 @@ -736,17 +967,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -755,29 +988,34 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_webhooks_operations.py index 1c92e7215ef9..7fe28f25aa44 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_webhooks_operations.py @@ -6,410 +6,421 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2021_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2021_12_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -420,16 +431,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,112 +448,131 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,18 +580,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -571,21 +679,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters 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 @@ -597,17 +709,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -616,65 +730,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -684,25 +807,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -714,83 +834,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -798,18 +942,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -817,21 +1041,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters 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 @@ -843,17 +1071,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -862,149 +1092,167 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2021_12_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1015,16 +1263,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1034,71 +1280,76 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-12-01-preview") # type: str + api_version: Literal["2021-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-12-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/__init__.py index 77e0de13a64c..0e99a7bac3b7 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_configuration.py index 69dd0bf3d87c..9eb5be3790a0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-02-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop("api_version", "2022-02-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - 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') + 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.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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_container_registry_management_client.py index c68da1538478..e654bf6cb4d4 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -56,9 +68,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2022_02_01_preview.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -76,31 +88,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -109,7 +126,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 @@ -122,15 +139,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ContainerRegistryManagementClient + def __enter__(self) -> "ContainerRegistryManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_metadata.json index 1f91b53af619..d9c77a239a96 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_metadata.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "tokens": "TokensOperations", "webhooks": "WebhooksOperations" } -} \ No newline at end of file +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_vendor.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_version.py index 9f8bb24bdd99..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/_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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/__init__.py index 41dd7f11c046..2b9f561654c9 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._container_registry_management_client import ContainerRegistryManagementClient -__all__ = ['ContainerRegistryManagementClient'] -# `._patch.py` 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 -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_configuration.py index 9e04ca77a6ba..1020682998f1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: 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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-02-01-preview". 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(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop("api_version", "2022-02-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,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-containerregistry/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-containerregistry/{}".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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_container_registry_management_client.py index 6410e19b9250..424e4c8bb029 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_container_registry_management_client.py @@ -9,20 +9,32 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ConnectedRegistriesOperations, ExportPipelinesOperations, ImportPipelinesOperations, Operations, PipelineRunsOperations, PrivateEndpointConnectionsOperations, RegistriesOperations, ReplicationsOperations, ScopeMapsOperations, TokensOperations, WebhooksOperations +from .operations import ( + ConnectedRegistriesOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerRegistryManagementClient. :ivar connected_registries: ConnectedRegistriesOperations operations @@ -57,9 +69,9 @@ class ContainerRegistryManagementClient: # pylint: disable=too-many-instance- :ivar webhooks: WebhooksOperations operations :vartype webhooks: azure.mgmt.containerregistry.v2022_02_01_preview.aio.operations.WebhooksOperations - :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 Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -77,31 +89,36 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerRegistryManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connected_registries = ConnectedRegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.export_pipelines = ExportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.import_pipelines = ImportPipelinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) self.webhooks = WebhooksOperations(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 @@ -110,7 +127,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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/_patch.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/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/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_connected_registries_operations.py index f4b0155827c1..bce05f130b6d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_connected_registries_operations.py @@ -6,61 +6,77 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._connected_registries_operations import build_create_request_initial, build_deactivate_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConnectedRegistriesOperations: - """ConnectedRegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -68,42 +84,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -114,16 +143,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,59 +161,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,72 +225,174 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -267,21 +400,25 @@ async def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry 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 @@ -294,17 +431,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -313,93 +452,100 @@ async def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -411,102 +557,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -514,21 +769,26 @@ async def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectedRegistry"]: + ) -> AsyncLROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -541,17 +801,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -560,93 +822,100 @@ async def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } async def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace_async - async def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -658,42 +927,50 @@ async def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deactivate_initial( + raw_result = await self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_export_pipelines_operations.py index 634b0fd1d1c9..9e3e949b609d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_export_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._export_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExportPipelinesOperations: - """ExportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +153,63 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,94 +217,119 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExportPipeline"]: + ) -> AsyncLROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline + :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 @@ -286,17 +342,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +444,100 @@ async def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -403,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_import_pipelines_operations.py index 11fe535d3db7..2bf1fc001360 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_import_pipelines_operations.py @@ -6,96 +6,125 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._import_pipelines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ImportPipelinesOperations: - """ImportPipelinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ImportPipelineListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +153,63 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,94 +217,119 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ImportPipeline"]: + ) -> AsyncLROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline + :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 @@ -286,17 +342,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +444,100 @@ async def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -403,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_operations.py index 2a6e7c95997b..d61c791352b6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_operations.py @@ -6,79 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -89,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,8 +134,6 @@ 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': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_pipeline_runs_operations.py index 57f42f9aec67..30a1279d2100 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_pipeline_runs_operations.py @@ -6,96 +6,123 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._pipeline_runs_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PipelineRunsOperations: - """PipelineRunsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,59 +151,63 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,72 +215,172 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -259,21 +388,25 @@ async def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PipelineRun"]: + ) -> AsyncLROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun 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 @@ -286,17 +419,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -305,93 +440,100 @@ async def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -403,42 +545,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_private_endpoint_connections_operations.py index 1658f10f5a3b..3277c34fafd8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,96 +6,126 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, 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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +136,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +153,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +287,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_02_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -257,22 +392,26 @@ async def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2022_02_01_preview.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 :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 @@ -285,17 +424,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -304,65 +445,74 @@ async def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,25 +522,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -402,42 +549,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_registries_operations.py index ab77599606f6..6d5fe58877e0 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_registries_operations.py @@ -6,82 +6,126 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._registries_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_generate_credentials_request_initial, build_get_private_link_resource_request, build_get_request, build_import_image_request_initial, build_list_by_resource_group_request, build_list_credentials_request, build_list_private_link_resources_request, build_list_request, build_list_usages_request, build_regenerate_credential_request, build_update_request_initial -T = TypeVar('T') +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_private_link_resource_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RegistriesOperations: - """RegistriesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -91,28 +135,105 @@ async def _import_image_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + async def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters 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 @@ -123,145 +244,228 @@ async def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_image_initial( + raw_result = await self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace_async + @overload async def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -272,16 +476,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -291,55 +493,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -350,16 +562,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -369,106 +579,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -476,36 +702,79 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 @@ -518,17 +787,51 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -536,63 +839,73 @@ async def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -602,22 +915,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -629,80 +938,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -710,37 +1043,117 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Registry"]: + ) -> AsyncLROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters 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 @@ -753,17 +1166,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -771,141 +1186,163 @@ async def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace_async async def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -916,16 +1353,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -935,59 +1370,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace_async async def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2022_02_01_preview.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -995,214 +1434,397 @@ async def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } async def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenerateCredentialsResult"]: + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters 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 @@ -1215,17 +1837,19 @@ async def begin_generate_credentials( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1233,29 +1857,34 @@ async def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_replications_operations.py index 966c21656f1b..82ba0672003e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_replications_operations.py @@ -6,96 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._replications_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ReplicationsOperations: - """ReplicationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -106,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,112 +151,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication, 'Replication') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -238,18 +285,99 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -257,20 +385,24 @@ async def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication 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 @@ -283,17 +415,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +436,74 @@ async def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +513,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -400,83 +540,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +648,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +749,25 @@ async def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Replication"]: + ) -> AsyncLROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters 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 @@ -530,17 +780,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,29 +801,34 @@ async def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_scope_maps_operations.py index 0ab2bfa256ba..d74cc728f678 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_scope_maps_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._scope_maps_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeMapsOperations: - """ScopeMapsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,59 +152,63 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,72 +216,172 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -258,21 +389,25 @@ async def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap 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 @@ -285,17 +420,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -304,93 +441,100 @@ async def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -402,102 +546,209 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -505,21 +756,25 @@ async def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ScopeMap"]: + ) -> AsyncLROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters 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 @@ -532,17 +787,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -551,29 +808,34 @@ async def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_tokens_operations.py index e2d6704ef73c..259670a4b52c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_tokens_operations.py @@ -6,95 +6,124 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._tokens_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TokensOperations: - """TokensOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,59 +152,61 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,72 +214,169 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -258,20 +384,25 @@ async def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token + 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 @@ -283,17 +414,19 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,93 +435,100 @@ async def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -400,102 +540,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +748,25 @@ async def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Token"]: + ) -> AsyncLROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters 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 @@ -529,17 +778,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -548,29 +799,34 @@ async def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_webhooks_operations.py index 5e53675a657f..b031abe48c66 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/aio/operations/_webhooks_operations.py @@ -6,95 +6,127 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._webhooks_operations import build_create_request_initial, build_delete_request_initial, build_get_callback_config_request, build_get_request, build_list_events_request, build_list_request, build_ping_request, build_update_request_initial -T = TypeVar('T') +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WebhooksOperations: - """WebhooksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -105,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,112 +154,133 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -237,18 +288,100 @@ async def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -256,21 +389,25 @@ async def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters 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 @@ -283,17 +420,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -302,65 +441,74 @@ async def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -370,25 +518,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -400,83 +545,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } async def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -484,18 +653,100 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -503,21 +754,25 @@ async def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Webhook"]: + ) -> AsyncLROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters 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 @@ -530,17 +785,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -549,149 +806,169 @@ async def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace_async async def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -702,16 +979,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,71 +996,76 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace_async async def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/__init__.py index 599d06b92cb1..f97e01719cf8 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/__init__.py @@ -114,192 +114,194 @@ from ._models_py3 import WebhookListResult from ._models_py3 import WebhookUpdateParameters - -from ._container_registry_management_client_enums import ( - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - AzureADAuthenticationAsArmPolicyStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import AzureADAuthenticationAsArmPolicyStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ActivationProperties', - 'ActiveDirectoryObject', - 'Actor', - 'AzureADAuthenticationAsArmPolicy', - 'CallbackConfig', - 'ConnectedRegistry', - 'ConnectedRegistryListResult', - 'ConnectedRegistryUpdateParameters', - 'EncryptionProperty', - 'ErrorResponse', - 'ErrorResponseBody', - 'Event', - 'EventContent', - 'EventInfo', - 'EventListResult', - 'EventRequestMessage', - 'EventResponseMessage', - 'ExportPipeline', - 'ExportPipelineListResult', - 'ExportPipelineTargetProperties', - 'ExportPolicy', - 'GenerateCredentialsParameters', - 'GenerateCredentialsResult', - 'IPRule', - 'IdentityProperties', - 'ImportImageParameters', - 'ImportPipeline', - 'ImportPipelineListResult', - 'ImportPipelineSourceProperties', - 'ImportSource', - 'ImportSourceCredentials', - 'InnerErrorDescription', - 'KeyVaultProperties', - 'LoggingProperties', - 'LoginServerProperties', - 'NetworkRuleSet', - 'OperationDefinition', - 'OperationDisplayDefinition', - 'OperationListResult', - 'OperationLogSpecificationDefinition', - 'OperationMetricSpecificationDefinition', - 'OperationServiceSpecificationDefinition', - 'PackageType', - 'ParentProperties', - 'PipelineRun', - 'PipelineRunListResult', - 'PipelineRunRequest', - 'PipelineRunResponse', - 'PipelineRunSourceProperties', - 'PipelineRunTargetProperties', - 'PipelineSourceTriggerDescriptor', - 'PipelineSourceTriggerProperties', - 'PipelineTriggerDescriptor', - 'PipelineTriggerProperties', - 'Policies', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProgressProperties', - 'ProxyResource', - 'QuarantinePolicy', - 'RegenerateCredentialParameters', - 'Registry', - 'RegistryListCredentialsResult', - 'RegistryListResult', - 'RegistryNameCheckRequest', - 'RegistryNameStatus', - 'RegistryPassword', - 'RegistryUpdateParameters', - 'RegistryUsage', - 'RegistryUsageListResult', - 'Replication', - 'ReplicationListResult', - 'ReplicationUpdateParameters', - 'Request', - 'Resource', - 'RetentionPolicy', - 'ScopeMap', - 'ScopeMapListResult', - 'ScopeMapUpdateParameters', - 'Sku', - 'SoftDeletePolicy', - 'Source', - 'Status', - 'StatusDetailProperties', - 'StorageAccountProperties', - 'SyncProperties', - 'SyncUpdateProperties', - 'SystemData', - 'Target', - 'TlsCertificateProperties', - 'TlsProperties', - 'Token', - 'TokenCertificate', - 'TokenCredentialsProperties', - 'TokenListResult', - 'TokenPassword', - 'TokenUpdateParameters', - 'TrustPolicy', - 'UserIdentityProperties', - 'Webhook', - 'WebhookCreateParameters', - 'WebhookListResult', - 'WebhookUpdateParameters', - 'Action', - 'ActionsRequired', - 'ActivationStatus', - 'AuditLogStatus', - 'AzureADAuthenticationAsArmPolicyStatus', - 'CertificateType', - 'ConnectedRegistryMode', - 'ConnectionState', - 'ConnectionStatus', - 'CreatedByType', - 'DefaultAction', - 'EncryptionStatus', - 'ExportPolicyStatus', - 'ImportMode', - 'LastModifiedByType', - 'LogLevel', - 'NetworkRuleBypassOptions', - 'PasswordName', - 'PipelineOptions', - 'PipelineRunSourceType', - 'PipelineRunTargetType', - 'PipelineSourceType', - 'PolicyStatus', - 'ProvisioningState', - 'PublicNetworkAccess', - 'RegistryUsageUnit', - 'ResourceIdentityType', - 'SkuName', - 'SkuTier', - 'TlsStatus', - 'TokenCertificateName', - 'TokenPasswordName', - 'TokenStatus', - 'TriggerStatus', - 'TrustPolicyType', - 'WebhookAction', - 'WebhookStatus', - 'ZoneRedundancy', + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "AzureADAuthenticationAsArmPolicy", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "PackageType", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "SoftDeletePolicy", + "Source", + "Status", + "StatusDetailProperties", + "StorageAccountProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "AzureADAuthenticationAsArmPolicyStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_container_registry_management_client_enums.py index c46d46b0bfaa..24cd3b201f09 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_container_registry_management_client_enums.py @@ -7,108 +7,107 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Action(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action of IP ACL rule. - """ +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of IP ACL rule.""" ALLOW = "Allow" -class ActionsRequired(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """A message indicating if changes on the service provider require any updates on the consumer. - """ + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" NONE = "None" RECREATE = "Recreate" -class ActivationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The activation status of the connected registry. - """ + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" ACTIVE = "Active" INACTIVE = "Inactive" -class AuditLogStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether audit logs are enabled on the connected registry. - """ + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class AzureADAuthenticationAsArmPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class AzureADAuthenticationAsArmPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class CertificateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of certificate location. - """ + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" LOCAL_DIRECTORY = "LocalDirectory" -class ConnectedRegistryMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The mode of the connected registry resource that indicates the permissions of the registry. - """ + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" READ_WRITE = "ReadWrite" READ_ONLY = "ReadOnly" REGISTRY = "Registry" MIRROR = "Mirror" -class ConnectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current connection state of the connected registry. - """ + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" ONLINE = "Online" OFFLINE = "Offline" SYNCING = "Syncing" UNHEALTHY = "Unhealthy" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The private link service connection status. - """ + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" APPROVED = "Approved" PENDING = "Pending" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default action of allow or deny when no other rules match. - """ + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" -class EncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not the encryption is enabled for container registry. - """ + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" ENABLED = "enabled" DISABLED = "disabled" -class ExportPolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. """ @@ -116,18 +115,18 @@ class ImportMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NO_FORCE = "NoForce" FORCE = "Force" -class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that last modified the resource. - """ + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The verbosity of logs persisted on the connected registry. - """ + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" DEBUG = "Debug" INFORMATION = "Information" @@ -135,55 +134,57 @@ class LogLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ERROR = "Error" NONE = "None" -class NetworkRuleBypassOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether to allow trusted Azure services to access a network restricted registry. - """ + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" AZURE_SERVICES = "AzureServices" NONE = "None" -class PasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name. - """ + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" PASSWORD = "password" PASSWORD2 = "password2" -class PipelineOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" OVERWRITE_TAGS = "OverwriteTags" OVERWRITE_BLOBS = "OverwriteBlobs" DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" CONTINUE_ON_ERRORS = "ContinueOnErrors" -class PipelineRunSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the source. - """ + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineRunTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the target. - """ + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" AZURE_STORAGE_BLOB = "AzureStorageBlob" -class PipelineSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of source for the import pipeline. - """ + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" -class PolicyStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The value that indicates whether the policy is enabled or not. - """ + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -192,87 +193,91 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public network access is allowed for the container registry. - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RegistryUsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement. - """ + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU name of the container registry. Required for registry creation. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" CLASSIC = "Classic" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" -class TlsStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether HTTPS is enabled for the login server. - """ + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TokenCertificateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" CERTIFICATE1 = "certificate1" CERTIFICATE2 = "certificate2" -class TokenPasswordName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The password name "password1" or "password2" - """ + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" PASSWORD1 = "password1" PASSWORD2 = "password2" -class TokenStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the token example enabled or disabled. - """ + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" ENABLED = "enabled" DISABLED = "disabled" -class TriggerStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the source trigger. - """ + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrustPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of trust policy. - """ + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" NOTARY = "Notary" -class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" PUSH = "push" DELETE = "delete" @@ -280,16 +285,16 @@ class WebhookAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CHART_PUSH = "chart_push" CHART_DELETE = "chart_delete" -class WebhookStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the webhook at the time the operation was called. - """ + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" ENABLED = "enabled" DISABLED = "disabled" -class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not zone redundancy is enabled for this container registry - """ + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_models_py3.py index e91c097b728f..767530bdd6f1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/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. @@ -7,44 +8,41 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._container_registry_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ActivationProperties(msrest.serialization.Model): +class ActivationProperties(_serialization.Model): """The activation properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The activation status of the connected registry. Possible values include: - "Active", "Inactive". + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ActivationStatus """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ActivationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None -class ActiveDirectoryObject(msrest.serialization.Model): +class ActiveDirectoryObject(_serialization.Model): """The Active Directory Object that will be used for authenticating the token of a container registry. :ivar object_id: The user/group/application object ID for Active Directory Object that will be @@ -56,17 +54,11 @@ class ActiveDirectoryObject(msrest.serialization.Model): """ _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - object_id: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): """ :keyword object_id: The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. @@ -75,12 +67,12 @@ def __init__( will be used for authenticating the token of a container registry. :paramtype tenant_id: str """ - super(ActiveDirectoryObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.object_id = object_id self.tenant_id = tenant_id -class Actor(msrest.serialization.Model): +class Actor(_serialization.Model): """The agent that initiated the event. For most situations, this could be from the authorization context of the request. :ivar name: The subject or username associated with the request context that generated the @@ -89,92 +81,76 @@ class Actor(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The subject or username associated with the request context that generated the event. :paramtype name: str """ - super(Actor, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class AzureADAuthenticationAsArmPolicy(msrest.serialization.Model): +class AzureADAuthenticationAsArmPolicy(_serialization.Model): """The policy for using ARM audience token for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.AzureADAuthenticationAsArmPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "AzureADAuthenticationAsArmPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.AzureADAuthenticationAsArmPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.AzureADAuthenticationAsArmPolicyStatus """ - super(AzureADAuthenticationAsArmPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class CallbackConfig(msrest.serialization.Model): +class CallbackConfig(_serialization.Model): """The configuration of service URI and custom headers for the webhook. All required parameters must be populated in order to send to Azure. - :ivar service_uri: Required. The service URI for the webhook to post notifications. + :ivar service_uri: The service URI for the webhook to post notifications. Required. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] """ _validation = { - 'service_uri': {'required': True}, + "service_uri": {"required": True}, } _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'customHeaders', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: str, - custom_headers: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword service_uri: Required. The service URI for the webhook to post notifications. + :keyword service_uri: The service URI for the webhook to post notifications. Required. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] """ - super(CallbackConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.custom_headers = custom_headers -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -190,33 +166,29 @@ class ProxyResource(msrest.serialization.Model): """ _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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ConnectedRegistry(ProxyResource): +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes """An object that represents a connected registry for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -229,18 +201,18 @@ class ConnectedRegistry(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState :ivar mode: The mode of the connected registry resource that indicates the permissions of the - registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :vartype mode: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryMode :ivar version: The current version of ACR runtime on the connected registry. :vartype version: str - :ivar connection_state: The current connection state of the connected registry. Possible values - include: "Online", "Offline", "Syncing", "Unhealthy". + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". :vartype connection_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectionState :ivar last_activity_time: The last activity time of the connected registry. @@ -267,51 +239,51 @@ class ConnectedRegistry(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'version': {'readonly': True}, - 'connection_state': {'readonly': True}, - 'last_activity_time': {'readonly': True}, - 'activation': {'readonly': True}, - 'status_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'connection_state': {'key': 'properties.connectionState', 'type': 'str'}, - 'last_activity_time': {'key': 'properties.lastActivityTime', 'type': 'iso-8601'}, - 'activation': {'key': 'properties.activation', 'type': 'ActivationProperties'}, - 'parent': {'key': 'properties.parent', 'type': 'ParentProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'LoginServerProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'status_details': {'key': 'properties.statusDetails', 'type': '[StatusDetailProperties]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - mode: Optional[Union[str, "ConnectedRegistryMode"]] = None, - parent: Optional["ParentProperties"] = None, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, client_token_ids: Optional[List[str]] = None, - login_server: Optional["LoginServerProperties"] = None, - logging: Optional["LoggingProperties"] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, notifications_list: Optional[List[str]] = None, **kwargs ): """ :keyword mode: The mode of the connected registry resource that indicates the permissions of - the registry. Possible values include: "ReadWrite", "ReadOnly", "Registry", "Mirror". + the registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". :paramtype mode: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryMode :keyword parent: The parent of the connected registry. @@ -328,7 +300,7 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistry, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.mode = mode self.version = None @@ -343,7 +315,7 @@ def __init__( self.notifications_list = notifications_list -class ConnectedRegistryListResult(msrest.serialization.Model): +class ConnectedRegistryListResult(_serialization.Model): """The result of a request to list connected registries for a container registry. :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink @@ -355,16 +327,12 @@ class ConnectedRegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectedRegistry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ConnectedRegistry"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of connected registries. Since this list may be incomplete, the @@ -374,12 +342,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of connected registries. :paramtype next_link: str """ - super(ConnectedRegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ConnectedRegistryUpdateParameters(msrest.serialization.Model): +class ConnectedRegistryUpdateParameters(_serialization.Model): """The parameters for updating a connected registry. :ivar sync_properties: The sync properties of the connected registry with its parent. @@ -396,17 +364,17 @@ class ConnectedRegistryUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sync_properties': {'key': 'properties.syncProperties', 'type': 'SyncUpdateProperties'}, - 'logging': {'key': 'properties.logging', 'type': 'LoggingProperties'}, - 'client_token_ids': {'key': 'properties.clientTokenIds', 'type': '[str]'}, - 'notifications_list': {'key': 'properties.notificationsList', 'type': '[str]'}, + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, } def __init__( self, *, - sync_properties: Optional["SyncUpdateProperties"] = None, - logging: Optional["LoggingProperties"] = None, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, client_token_ids: Optional[List[str]] = None, notifications_list: Optional[List[str]] = None, **kwargs @@ -424,18 +392,18 @@ def __init__( connected registry. :paramtype notifications_list: list[str] """ - super(ConnectedRegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sync_properties = sync_properties self.logging = logging self.client_token_ids = client_token_ids self.notifications_list = notifications_list -class EncryptionProperty(msrest.serialization.Model): +class EncryptionProperty(_serialization.Model): """EncryptionProperty. - :ivar status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.EncryptionStatus :ivar key_vault_properties: Key vault properties. @@ -444,32 +412,32 @@ class EncryptionProperty(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionStatus"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword status: Indicates whether or not the encryption is enabled for container registry. - Possible values include: "enabled", "disabled". + Known values are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.EncryptionStatus :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.KeyVaultProperties """ - super(EncryptionProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the Azure Container Registry service. :ivar error: Azure container registry build API error body. @@ -477,31 +445,26 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure container registry build API error body. :paramtype error: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """An error response from the Azure Container Registry service. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str @@ -512,15 +475,15 @@ class ErrorResponseBody(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[InnerErrorDescription]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, } def __init__( @@ -529,13 +492,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["InnerErrorDescription"]] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, **kwargs ): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str @@ -544,14 +507,14 @@ def __init__( :paramtype details: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.InnerErrorDescription] """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class EventInfo(msrest.serialization.Model): +class EventInfo(_serialization.Model): """The basic information of an event. :ivar id: The event ID. @@ -559,20 +522,15 @@ class EventInfo(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 event ID. :paramtype id: str """ - super(EventInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -590,17 +548,17 @@ class Event(EventInfo): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'event_request_message': {'key': 'eventRequestMessage', 'type': 'EventRequestMessage'}, - 'event_response_message': {'key': 'eventResponseMessage', 'type': 'EventResponseMessage'}, + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, } def __init__( self, *, - id: Optional[str] = None, - event_request_message: Optional["EventRequestMessage"] = None, - event_response_message: Optional["EventResponseMessage"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, **kwargs ): """ @@ -613,12 +571,12 @@ def __init__( :paramtype event_response_message: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.EventResponseMessage """ - super(Event, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.event_request_message = event_request_message self.event_response_message = event_response_message -class EventContent(msrest.serialization.Model): +class EventContent(_serialization.Model): """The content of the event request message. :ivar id: The event ID. @@ -640,25 +598,25 @@ class EventContent(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'action': {'key': 'action', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'Target'}, - 'request': {'key': 'request', 'type': 'Request'}, - 'actor': {'key': 'actor', 'type': 'Actor'}, - 'source': {'key': 'source', 'type': 'Source'}, + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin timestamp: Optional[datetime.datetime] = None, action: Optional[str] = None, - target: Optional["Target"] = None, - request: Optional["Request"] = None, - actor: Optional["Actor"] = None, - source: Optional["Source"] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, **kwargs ): """ @@ -679,7 +637,7 @@ def __init__( initiates the event, the source generates it. :paramtype source: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Source """ - super(EventContent, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.timestamp = timestamp self.action = action @@ -689,7 +647,7 @@ def __init__( self.source = source -class EventListResult(msrest.serialization.Model): +class EventListResult(_serialization.Model): """The result of a request to list events for a webhook. :ivar value: The list of events. Since this list may be incomplete, the nextLink field should @@ -700,17 +658,11 @@ class EventListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Event]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Event"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. @@ -718,12 +670,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of events. :paramtype next_link: str """ - super(EventListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventRequestMessage(msrest.serialization.Model): +class EventRequestMessage(_serialization.Model): """The event request message sent to the service URI. :ivar content: The content of the event request message. @@ -739,17 +691,17 @@ class EventRequestMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'EventContent'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'method': {'key': 'method', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( self, *, - content: Optional["EventContent"] = None, + content: Optional["_models.EventContent"] = None, headers: Optional[Dict[str, str]] = None, method: Optional[str] = None, request_uri: Optional[str] = None, @@ -768,7 +720,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventRequestMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.method = method @@ -776,7 +728,7 @@ def __init__( self.version = version -class EventResponseMessage(msrest.serialization.Model): +class EventResponseMessage(_serialization.Model): """The event response message received from the service URI. :ivar content: The content of the event response message. @@ -792,11 +744,11 @@ class EventResponseMessage(msrest.serialization.Model): """ _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'headers': {'key': 'headers', 'type': '{str}'}, - 'reason_phrase': {'key': 'reasonPhrase', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -821,7 +773,7 @@ def __init__( :keyword version: The HTTP message version. :paramtype version: str """ - super(EventResponseMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content self.headers = headers self.reason_phrase = reason_phrase @@ -853,39 +805,39 @@ class ExportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'target': {'key': 'properties.target', 'type': 'ExportPipelineTargetProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -901,7 +853,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineOptions] """ - super(ExportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.target = target @@ -909,7 +861,7 @@ def __init__( self.provisioning_state = None -class ExportPipelineListResult(msrest.serialization.Model): +class ExportPipelineListResult(_serialization.Model): """The result of a request to list export pipelines for a container registry. :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -920,16 +872,12 @@ class ExportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink @@ -938,12 +886,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ExportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExportPipelineTargetProperties(msrest.serialization.Model): +class ExportPipelineTargetProperties(_serialization.Model): """The properties of the export pipeline target. All required parameters must be populated in order to send to Azure. @@ -954,29 +902,22 @@ class ExportPipelineTargetProperties(msrest.serialization.Model): When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_vault_uri: str, - type: Optional[str] = None, - uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): """ :keyword type: The type of target for the export pipeline. :paramtype type: str @@ -984,46 +925,41 @@ def __init__( When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the target storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ExportPipelineTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ExportPolicy(msrest.serialization.Model): +class ExportPolicy(_serialization.Model): """The export policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "ExportPolicyStatus"]] = "enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". Default value: "enabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPolicyStatus """ - super(ExportPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class GenerateCredentialsParameters(msrest.serialization.Model): +class GenerateCredentialsParameters(_serialization.Model): """The parameters used to generate credentials for a specified token or user of a container registry. :ivar token_id: The resource ID of the token for which credentials have to be generated. @@ -1032,15 +968,15 @@ class GenerateCredentialsParameters(msrest.serialization.Model): invalid. :vartype expiry: ~datetime.datetime :ivar name: Specifies name of the password which should be regenerated if any -- password1 or - password2. Possible values include: "password1", "password2". + password2. Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPasswordName """ _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1048,7 +984,7 @@ def __init__( *, token_id: Optional[str] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -1058,17 +994,17 @@ def __init__( become invalid. :paramtype expiry: ~datetime.datetime :keyword name: Specifies name of the password which should be regenerated if any -- password1 - or password2. Possible values include: "password1", "password2". + or password2. Known values are: "password1" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPasswordName """ - super(GenerateCredentialsParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.expiry = expiry self.name = name -class GenerateCredentialsResult(msrest.serialization.Model): +class GenerateCredentialsResult(_serialization.Model): """The response from the GenerateCredentials operation. :ivar username: The username for a container registry. @@ -1079,16 +1015,12 @@ class GenerateCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["TokenPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -1097,20 +1029,20 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPassword] """ - super(GenerateCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class IdentityProperties(msrest.serialization.Model): +class IdentityProperties(_serialization.Model): """Managed identity for the resource. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1123,10 +1055,10 @@ class IdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( @@ -1134,8 +1066,8 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ @@ -1143,8 +1075,8 @@ def __init__( :paramtype principal_id: str :keyword tenant_id: The tenant ID of resource. :paramtype tenant_id: str - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1155,19 +1087,19 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.containerregistry.v2022_02_01_preview.models.UserIdentityProperties] """ - super(IdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type self.user_assigned_identities = user_assigned_identities -class ImportImageParameters(msrest.serialization.Model): +class ImportImageParameters(_serialization.Model): """ImportImageParameters. All required parameters must be populated in order to send to Azure. - :ivar source: Required. The source of the image. + :ivar source: The source of the image. Required. :vartype source: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportSource :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1176,33 +1108,33 @@ class ImportImageParameters(msrest.serialization.Model): copy. No tag will be created. :vartype untagged_target_repositories: list[str] :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :vartype mode: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportMode """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { - 'source': {'key': 'source', 'type': 'ImportSource'}, - 'target_tags': {'key': 'targetTags', 'type': '[str]'}, - 'untagged_target_repositories': {'key': 'untaggedTargetRepositories', 'type': '[str]'}, - 'mode': {'key': 'mode', 'type': 'str'}, + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, } def __init__( self, *, - source: "ImportSource", + source: "_models.ImportSource", target_tags: Optional[List[str]] = None, untagged_target_repositories: Optional[List[str]] = None, - mode: Optional[Union[str, "ImportMode"]] = "NoForce", + mode: Union[str, "_models.ImportMode"] = "NoForce", **kwargs ): """ - :keyword source: Required. The source of the image. + :keyword source: The source of the image. Required. :paramtype source: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportSource :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). @@ -1211,11 +1143,11 @@ def __init__( only copy. No tag will be created. :paramtype untagged_target_repositories: list[str] :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any - existing target tags will fail the operation before any copying begins. Possible values - include: "NoForce", "Force". Default value: "NoForce". + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". :paramtype mode: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportMode """ - super(ImportImageParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.target_tags = target_tags self.untagged_target_repositories = untagged_target_repositories @@ -1249,41 +1181,41 @@ class ImportPipeline(ProxyResource): :vartype options: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineOptions] :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'source': {'key': 'properties.source', 'type': 'ImportPipelineSourceProperties'}, - 'trigger': {'key': 'properties.trigger', 'type': 'PipelineTriggerProperties'}, - 'options': {'key': 'properties.options', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["IdentityProperties"] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - trigger: Optional["PipelineTriggerProperties"] = None, - options: Optional[List[Union[str, "PipelineOptions"]]] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, **kwargs ): """ @@ -1302,7 +1234,7 @@ def __init__( :paramtype options: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineOptions] """ - super(ImportPipeline, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity self.source = source @@ -1311,7 +1243,7 @@ def __init__( self.provisioning_state = None -class ImportPipelineListResult(msrest.serialization.Model): +class ImportPipelineListResult(_serialization.Model): """The result of a request to list import pipelines for a container registry. :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1322,16 +1254,12 @@ class ImportPipelineListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ImportPipeline]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ImportPipeline"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink @@ -1340,67 +1268,65 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(ImportPipelineListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ImportPipelineSourceProperties(msrest.serialization.Model): +class ImportPipelineSourceProperties(_serialization.Model): """The properties of the import pipeline source. All required parameters must be populated in order to send to Azure. - :ivar type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineSourceType :ivar uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :vartype uri: str - :ivar key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :vartype key_vault_uri: str """ _validation = { - 'key_vault_uri': {'required': True}, + "key_vault_uri": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } def __init__( self, *, key_vault_uri: str, - type: Optional[Union[str, "PipelineSourceType"]] = "AzureStorageBlobContainer", + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", uri: Optional[str] = None, **kwargs ): """ - :keyword type: The type of source for the import pipeline. Possible values include: - "AzureStorageBlobContainer". Default value: "AzureStorageBlobContainer". + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" :paramtype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineSourceType :keyword uri: The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". :paramtype uri: str - :keyword key_vault_uri: Required. They key vault secret uri to obtain the source storage SAS - token. + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. :paramtype key_vault_uri: str """ - super(ImportPipelineSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.uri = uri self.key_vault_uri = key_vault_uri -class ImportSource(msrest.serialization.Model): +class ImportSource(_serialization.Model): """ImportSource. All required parameters must be populated in order to send to Azure. @@ -1412,22 +1338,22 @@ class ImportSource(msrest.serialization.Model): :ivar credentials: Credentials used when importing from a registry uri. :vartype credentials: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportSourceCredentials - :ivar source_image: Required. Repository name of the source image. + :ivar source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :vartype source_image: str """ _validation = { - 'source_image': {'required': True}, + "source_image": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'registry_uri': {'key': 'registryUri', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'ImportSourceCredentials'}, - 'source_image': {'key': 'sourceImage', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, } def __init__( @@ -1436,7 +1362,7 @@ def __init__( source_image: str, resource_id: Optional[str] = None, registry_uri: Optional[str] = None, - credentials: Optional["ImportSourceCredentials"] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, **kwargs ): """ @@ -1447,146 +1373,125 @@ def __init__( :keyword credentials: Credentials used when importing from a registry uri. :paramtype credentials: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportSourceCredentials - :keyword source_image: Required. Repository name of the source image. + :keyword source_image: Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag ('hello-world:latest'). - Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. :paramtype source_image: str """ - super(ImportSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.registry_uri = registry_uri self.credentials = credentials self.source_image = source_image -class ImportSourceCredentials(msrest.serialization.Model): +class ImportSourceCredentials(_serialization.Model): """ImportSourceCredentials. All required parameters must be populated in order to send to Azure. :ivar username: The username to authenticate with the source registry. :vartype username: str - :ivar password: Required. The password used to authenticate with the source registry. + :ivar password: The password used to authenticate with the source registry. Required. :vartype password: str """ _validation = { - 'password': {'required': True}, + "password": {"required": True}, } _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - password: str, - username: Optional[str] = None, - **kwargs - ): + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): """ :keyword username: The username to authenticate with the source registry. :paramtype username: str - :keyword password: Required. The password used to authenticate with the source registry. + :keyword password: The password used to authenticate with the source registry. Required. :paramtype password: str """ - super(ImportSourceCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.password = password -class InnerErrorDescription(msrest.serialization.Model): +class InnerErrorDescription(_serialization.Model): """inner error. All required parameters must be populated in order to send to Azure. - :ivar code: Required. error code. + :ivar code: error code. Required. :vartype code: str - :ivar message: Required. error message. + :ivar message: error message. Required. :vartype message: str :ivar target: target of the particular error. :vartype target: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): """ - :keyword code: Required. error code. + :keyword code: error code. Required. :paramtype code: str - :keyword message: Required. error message. + :keyword message: error message. Required. :paramtype message: str :keyword target: target of the particular error. :paramtype target: str """ - super(InnerErrorDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar action: The action of IP ACL rule. Possible values include: "Allow". Default value: - "Allow". + :ivar action: The action of IP ACL rule. "Allow" :vartype action: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Action - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[Union[str, "Action"]] = "Allow", - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Union[str, "_models.Action"] = "Allow", **kwargs): """ - :keyword action: The action of IP ACL rule. Possible values include: "Allow". Default value: - "Allow". + :keyword action: The action of IP ACL rule. "Allow" :paramtype action: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Action - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.ip_address_or_range = ip_address_or_range -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. @@ -1605,33 +1510,27 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'versioned_key_identifier': {'readonly': True}, - 'key_rotation_enabled': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'versioned_key_identifier': {'key': 'versionedKeyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'key_rotation_enabled': {'key': 'keyRotationEnabled', 'type': 'bool'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_identifier: Optional[str] = None, - identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): """ :keyword key_identifier: Key vault uri to access the encryption key. :paramtype key_identifier: str :keyword identity: The client id of the identity which will be used to access key vault. :paramtype identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_identifier = key_identifier self.versioned_key_identifier = None self.identity = identity @@ -1639,45 +1538,45 @@ def __init__( self.last_key_rotation_timestamp = None -class LoggingProperties(msrest.serialization.Model): +class LoggingProperties(_serialization.Model): """The logging properties of the connected registry. - :ivar log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". :vartype log_level: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.LogLevel :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :vartype audit_log_status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.AuditLogStatus """ _attribute_map = { - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'audit_log_status': {'key': 'auditLogStatus', 'type': 'str'}, + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, } def __init__( self, *, - log_level: Optional[Union[str, "LogLevel"]] = "Information", - audit_log_status: Optional[Union[str, "AuditLogStatus"]] = "Disabled", + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", **kwargs ): """ - :keyword log_level: The verbosity of logs persisted on the connected registry. Possible values - include: "Debug", "Information", "Warning", "Error", "None". Default value: "Information". + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". :paramtype log_level: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.LogLevel :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. - Possible values include: "Enabled", "Disabled". Default value: "Disabled". + Known values are: "Enabled" and "Disabled". :paramtype audit_log_status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.AuditLogStatus """ - super(LoggingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_level = log_level self.audit_log_status = audit_log_status -class LoginServerProperties(msrest.serialization.Model): +class LoginServerProperties(_serialization.Model): """The login server properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -1689,33 +1588,29 @@ class LoginServerProperties(msrest.serialization.Model): """ _validation = { - 'host': {'readonly': True}, - 'tls': {'readonly': True}, + "host": {"readonly": True}, + "tls": {"readonly": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'tls': {'key': 'tls', 'type': 'TlsProperties'}, + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LoginServerProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.host = None self.tls = None -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """The network rule set for a container registry. All required parameters must be populated in order to send to Azure. - :ivar default_action: Required. The default action of allow or deny when no other rules match. - Possible values include: "Allow", "Deny". Default value: "Allow". + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.DefaultAction :ivar ip_rules: The IP ACL rules. @@ -1723,35 +1618,35 @@ class NetworkRuleSet(msrest.serialization.Model): """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, } def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ - :keyword default_action: Required. The default action of allow or deny when no other rules - match. Possible values include: "Allow", "Deny". Default value: "Allow". + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.DefaultAction :keyword ip_rules: The IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.IPRule] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.ip_rules = ip_rules -class OperationDefinition(msrest.serialization.Model): +class OperationDefinition(_serialization.Model): """The definition of a container registry operation. :ivar origin: The origin information of the container registry operation. @@ -1771,11 +1666,14 @@ class OperationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'origin': {'key': 'origin', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayDefinition'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationServiceSpecificationDefinition'}, + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, } def __init__( @@ -1783,9 +1681,9 @@ def __init__( *, origin: Optional[str] = None, name: Optional[str] = None, - display: Optional["OperationDisplayDefinition"] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["OperationServiceSpecificationDefinition"] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, **kwargs ): """ @@ -1804,7 +1702,7 @@ def __init__( :paramtype service_specification: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationServiceSpecificationDefinition """ - super(OperationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.origin = origin self.name = name self.display = display @@ -1812,7 +1710,7 @@ def __init__( self.service_specification = service_specification -class OperationDisplayDefinition(msrest.serialization.Model): +class OperationDisplayDefinition(_serialization.Model): """The display information for a container registry operation. :ivar provider: The resource provider name: Microsoft.ContainerRegistry. @@ -1826,10 +1724,10 @@ class OperationDisplayDefinition(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__( @@ -1851,14 +1749,14 @@ def __init__( :keyword description: The description for the operation. :paramtype description: str """ - super(OperationDisplayDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """The result of a request to list container registry operations. :ivar value: The list of container registry operations. Since this list may be incomplete, the @@ -1871,16 +1769,12 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of container registry operations. Since this list may be incomplete, @@ -1891,12 +1785,12 @@ def __init__( operations. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationLogSpecificationDefinition(msrest.serialization.Model): +class OperationLogSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring log. :ivar name: Log name. @@ -1908,9 +1802,9 @@ class OperationLogSpecificationDefinition(msrest.serialization.Model): """ _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__( @@ -1929,13 +1823,13 @@ def __init__( :keyword blob_duration: Log blob duration. :paramtype blob_duration: str """ - super(OperationLogSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class OperationMetricSpecificationDefinition(msrest.serialization.Model): +class OperationMetricSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring metric. :ivar name: Metric name. @@ -1953,12 +1847,12 @@ class OperationMetricSpecificationDefinition(msrest.serialization.Model): """ _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'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1986,7 +1880,7 @@ def __init__( :keyword internal_metric_name: Internal metric name. :paramtype internal_metric_name: str """ - super(OperationMetricSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1995,7 +1889,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class OperationServiceSpecificationDefinition(msrest.serialization.Model): +class OperationServiceSpecificationDefinition(_serialization.Model): """The definition of Azure Monitoring list. :ivar metric_specifications: A list of Azure Monitoring metrics definition. @@ -2007,15 +1901,15 @@ class OperationServiceSpecificationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetricSpecificationDefinition]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationLogSpecificationDefinition]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetricSpecificationDefinition"]] = None, - log_specifications: Optional[List["OperationLogSpecificationDefinition"]] = None, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, **kwargs ): """ @@ -2026,12 +1920,12 @@ def __init__( :paramtype log_specifications: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationLogSpecificationDefinition] """ - super(OperationServiceSpecificationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class PackageType(msrest.serialization.Model): +class PackageType(_serialization.Model): """The properties of a package type. Variables are only populated by the server, and will be ignored when sending a request. @@ -2043,66 +1937,61 @@ class PackageType(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: The name of the package type. :paramtype name: str """ - super(PackageType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.endpoint = None -class ParentProperties(msrest.serialization.Model): +class ParentProperties(_serialization.Model): """The properties of the connected registry parent. All required parameters must be populated in order to send to Azure. :ivar id: The resource ID of the parent to which the connected registry will be associated. :vartype id: str - :ivar sync_properties: Required. The sync properties of the connected registry with its parent. + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. :vartype sync_properties: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SyncProperties """ _validation = { - 'sync_properties': {'required': True}, + "sync_properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'sync_properties': {'key': 'syncProperties', 'type': 'SyncProperties'}, + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, } def __init__( self, *, - sync_properties: "SyncProperties", - id: Optional[str] = None, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: The resource ID of the parent to which the connected registry will be associated. :paramtype id: str - :keyword sync_properties: Required. The sync properties of the connected registry with its - parent. + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. :paramtype sync_properties: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SyncProperties """ - super(ParentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.sync_properties = sync_properties @@ -2120,8 +2009,8 @@ class PipelineRun(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of a pipeline run. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState :ivar request: The request parameters for a pipeline run. @@ -2134,29 +2023,29 @@ class PipelineRun(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'response': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'PipelineRunRequest'}, - 'response': {'key': 'properties.response', 'type': 'PipelineRunResponse'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, } def __init__( self, *, - request: Optional["PipelineRunRequest"] = None, + request: Optional["_models.PipelineRunRequest"] = None, force_update_tag: Optional[str] = None, **kwargs ): @@ -2167,14 +2056,14 @@ def __init__( pipeline run configuration has not changed. :paramtype force_update_tag: str """ - super(PipelineRun, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.request = request self.response = None self.force_update_tag = force_update_tag -class PipelineRunListResult(msrest.serialization.Model): +class PipelineRunListResult(_serialization.Model): """The result of a request to list pipeline runs for a container registry. :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field @@ -2185,16 +2074,12 @@ class PipelineRunListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PipelineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PipelineRun"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink @@ -2203,12 +2088,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of pipeline runs. :paramtype next_link: str """ - super(PipelineRunListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PipelineRunRequest(msrest.serialization.Model): +class PipelineRunRequest(_serialization.Model): """The request properties provided for a pipeline run. :ivar pipeline_resource_id: The resource ID of the pipeline to run. @@ -2229,11 +2114,11 @@ class PipelineRunRequest(msrest.serialization.Model): """ _attribute_map = { - 'pipeline_resource_id': {'key': 'pipelineResourceId', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': '[str]'}, - 'source': {'key': 'source', 'type': 'PipelineRunSourceProperties'}, - 'target': {'key': 'target', 'type': 'PipelineRunTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, } def __init__( @@ -2241,8 +2126,8 @@ def __init__( *, pipeline_resource_id: Optional[str] = None, artifacts: Optional[List[str]] = None, - source: Optional["PipelineRunSourceProperties"] = None, - target: Optional["PipelineRunTargetProperties"] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, catalog_digest: Optional[str] = None, **kwargs ): @@ -2263,7 +2148,7 @@ def __init__( :keyword catalog_digest: The digest of the tar used to transfer the artifacts. :paramtype catalog_digest: str """ - super(PipelineRunRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.pipeline_resource_id = pipeline_resource_id self.artifacts = artifacts self.source = source @@ -2271,7 +2156,7 @@ def __init__( self.catalog_digest = catalog_digest -class PipelineRunResponse(msrest.serialization.Model): +class PipelineRunResponse(_serialization.Model): """The response properties returned for a pipeline run. :ivar status: The current status of the pipeline run. @@ -2301,16 +2186,16 @@ class PipelineRunResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'imported_artifacts': {'key': 'importedArtifacts', 'type': '[str]'}, - 'progress': {'key': 'progress', 'type': 'ProgressProperties'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'finish_time': {'key': 'finishTime', 'type': 'iso-8601'}, - 'source': {'key': 'source', 'type': 'ImportPipelineSourceProperties'}, - 'target': {'key': 'target', 'type': 'ExportPipelineTargetProperties'}, - 'catalog_digest': {'key': 'catalogDigest', 'type': 'str'}, - 'trigger': {'key': 'trigger', 'type': 'PipelineTriggerDescriptor'}, - 'pipeline_run_error_message': {'key': 'pipelineRunErrorMessage', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, } def __init__( @@ -2318,13 +2203,13 @@ def __init__( *, status: Optional[str] = None, imported_artifacts: Optional[List[str]] = None, - progress: Optional["ProgressProperties"] = None, + progress: Optional["_models.ProgressProperties"] = None, start_time: Optional[datetime.datetime] = None, finish_time: Optional[datetime.datetime] = None, - source: Optional["ImportPipelineSourceProperties"] = None, - target: Optional["ExportPipelineTargetProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, catalog_digest: Optional[str] = None, - trigger: Optional["PipelineTriggerDescriptor"] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, pipeline_run_error_message: Optional[str] = None, **kwargs ): @@ -2355,7 +2240,7 @@ def __init__( case of failure. :paramtype pipeline_run_error_message: str """ - super(PipelineRunResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.imported_artifacts = imported_artifacts self.progress = progress @@ -2368,11 +2253,10 @@ def __init__( self.pipeline_run_error_message = pipeline_run_error_message -class PipelineRunSourceProperties(msrest.serialization.Model): +class PipelineRunSourceProperties(_serialization.Model): """PipelineRunSourceProperties. - :ivar type: The type of the source. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the source. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunSourceType :ivar name: The name of the source. @@ -2380,35 +2264,33 @@ class PipelineRunSourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunSourceType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the source. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the source. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunSourceType :keyword name: The name of the source. :paramtype name: str """ - super(PipelineRunSourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineRunTargetProperties(msrest.serialization.Model): +class PipelineRunTargetProperties(_serialization.Model): """PipelineRunTargetProperties. - :ivar type: The type of the target. Possible values include: "AzureStorageBlob". Default value: - "AzureStorageBlob". + :ivar type: The type of the target. "AzureStorageBlob" :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunTargetType :ivar name: The name of the target. @@ -2416,31 +2298,30 @@ class PipelineRunTargetProperties(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "PipelineRunTargetType"]] = "AzureStorageBlob", + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of the target. Possible values include: "AzureStorageBlob". Default - value: "AzureStorageBlob". + :keyword type: The type of the target. "AzureStorageBlob" :paramtype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunTargetType :keyword name: The name of the target. :paramtype name: str """ - super(PipelineRunTargetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class PipelineSourceTriggerDescriptor(msrest.serialization.Model): +class PipelineSourceTriggerDescriptor(_serialization.Model): """PipelineSourceTriggerDescriptor. :ivar timestamp: The timestamp when the source update happened. @@ -2448,58 +2329,48 @@ class PipelineSourceTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The timestamp when the source update happened. :paramtype timestamp: ~datetime.datetime """ - super(PipelineSourceTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class PipelineSourceTriggerProperties(msrest.serialization.Model): +class PipelineSourceTriggerProperties(_serialization.Model): """PipelineSourceTriggerProperties. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TriggerStatus """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "TriggerStatus"] = "Enabled", - **kwargs - ): + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): """ - :keyword status: Required. The current status of the source trigger. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TriggerStatus """ - super(PipelineSourceTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class PipelineTriggerDescriptor(msrest.serialization.Model): +class PipelineTriggerDescriptor(_serialization.Model): """PipelineTriggerDescriptor. :ivar source_trigger: The source trigger that caused the pipeline run. @@ -2508,25 +2379,20 @@ class PipelineTriggerDescriptor(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerDescriptor'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerDescriptor"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): """ :keyword source_trigger: The source trigger that caused the pipeline run. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineSourceTriggerDescriptor """ - super(PipelineTriggerDescriptor, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class PipelineTriggerProperties(msrest.serialization.Model): +class PipelineTriggerProperties(_serialization.Model): """PipelineTriggerProperties. :ivar source_trigger: The source trigger properties of the pipeline. @@ -2535,25 +2401,20 @@ class PipelineTriggerProperties(msrest.serialization.Model): """ _attribute_map = { - 'source_trigger': {'key': 'sourceTrigger', 'type': 'PipelineSourceTriggerProperties'}, + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, } - def __init__( - self, - *, - source_trigger: Optional["PipelineSourceTriggerProperties"] = None, - **kwargs - ): + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): """ :keyword source_trigger: The source trigger properties of the pipeline. :paramtype source_trigger: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineSourceTriggerProperties """ - super(PipelineTriggerProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_trigger = source_trigger -class Policies(msrest.serialization.Model): +class Policies(_serialization.Model): """The policies for a container registry. :ivar quarantine_policy: The quarantine policy for a container registry. @@ -2576,23 +2437,26 @@ class Policies(msrest.serialization.Model): """ _attribute_map = { - 'quarantine_policy': {'key': 'quarantinePolicy', 'type': 'QuarantinePolicy'}, - 'trust_policy': {'key': 'trustPolicy', 'type': 'TrustPolicy'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - 'export_policy': {'key': 'exportPolicy', 'type': 'ExportPolicy'}, - 'azure_ad_authentication_as_arm_policy': {'key': 'azureADAuthenticationAsArmPolicy', 'type': 'AzureADAuthenticationAsArmPolicy'}, - 'soft_delete_policy': {'key': 'softDeletePolicy', 'type': 'SoftDeletePolicy'}, + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, + "azure_ad_authentication_as_arm_policy": { + "key": "azureADAuthenticationAsArmPolicy", + "type": "AzureADAuthenticationAsArmPolicy", + }, + "soft_delete_policy": {"key": "softDeletePolicy", "type": "SoftDeletePolicy"}, } def __init__( self, *, - quarantine_policy: Optional["QuarantinePolicy"] = None, - trust_policy: Optional["TrustPolicy"] = None, - retention_policy: Optional["RetentionPolicy"] = None, - export_policy: Optional["ExportPolicy"] = None, - azure_ad_authentication_as_arm_policy: Optional["AzureADAuthenticationAsArmPolicy"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, + azure_ad_authentication_as_arm_policy: Optional["_models.AzureADAuthenticationAsArmPolicy"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -2614,7 +2478,7 @@ def __init__( :paramtype soft_delete_policy: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SoftDeletePolicy """ - super(Policies, self).__init__(**kwargs) + super().__init__(**kwargs) self.quarantine_policy = quarantine_policy self.trust_policy = trust_policy self.retention_policy = retention_policy @@ -2623,7 +2487,7 @@ def __init__( self.soft_delete_policy = soft_delete_policy -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. @@ -2631,21 +2495,16 @@ class PrivateEndpoint(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: This is private endpoint resource created with Microsoft.Network resource provider. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -2669,35 +2528,38 @@ class PrivateEndpointConnection(ProxyResource): connection between service consumer and provider. :vartype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of private endpoint connection resource. - Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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'}, - '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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "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__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2709,13 +2571,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.containerregistry.v2022_02_01_preview.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): """The result of a request to list private endpoint connections for a container registry. :ivar value: The list of private endpoint connections. Since this list may be incomplete, the @@ -2728,14 +2590,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2748,12 +2610,12 @@ def __init__( connections. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """A resource that supports private link capabilities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2773,22 +2635,22 @@ class PrivateLinkResource(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, + "type": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, group_id: Optional[str] = None, required_members: Optional[List[str]] = None, @@ -2807,7 +2669,7 @@ def __init__( :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.type = None self.id = id self.name = name @@ -2816,7 +2678,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """The result of a request to list private link resources for a container registry. :ivar value: The list of private link resources. Since this list may be incomplete, the @@ -2828,16 +2690,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of private link resources. Since this list may be incomplete, the @@ -2848,61 +2706,61 @@ def __init__( resources. :paramtype next_link: str """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The state of a private link service connection. - :ivar status: The private link service connection status. Possible values include: "Approved", - "Pending", "Rejected", "Disconnected". + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectionStatus :ivar description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :vartype description: str :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :vartype actions_required: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ActionsRequired """ _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__( self, *, - status: Optional[Union[str, "ConnectionStatus"]] = None, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, description: Optional[str] = None, - actions_required: Optional[Union[str, "ActionsRequired"]] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, **kwargs ): """ - :keyword status: The private link service connection status. Possible values include: - "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectionStatus :keyword description: The description for connection status. For example if connection is rejected it can indicate reason for rejection. :paramtype description: str :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. Possible values include: "None", "Recreate". + updates on the consumer. Known values are: "None" and "Recreate". :paramtype actions_required: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ActionsRequired """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class ProgressProperties(msrest.serialization.Model): +class ProgressProperties(_serialization.Model): """ProgressProperties. :ivar percentage: The percentage complete of the copy operation. @@ -2910,84 +2768,69 @@ class ProgressProperties(msrest.serialization.Model): """ _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'str'}, + "percentage": {"key": "percentage", "type": "str"}, } - def __init__( - self, - *, - percentage: Optional[str] = None, - **kwargs - ): + def __init__(self, *, percentage: Optional[str] = None, **kwargs): """ :keyword percentage: The percentage complete of the copy operation. :paramtype percentage: str """ - super(ProgressProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.percentage = percentage -class QuarantinePolicy(msrest.serialization.Model): +class QuarantinePolicy(_serialization.Model): """The quarantine policy for a container registry. - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ - super(QuarantinePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status -class RegenerateCredentialParameters(msrest.serialization.Model): +class RegenerateCredentialParameters(_serialization.Model): """The parameters used to regenerate the login credential. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Specifies name of the password which should be regenerated -- password or - password2. Possible values include: "password", "password2". + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PasswordName """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "PasswordName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): """ - :keyword name: Required. Specifies name of the password which should be regenerated -- password - or password2. Possible values include: "password", "password2". + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PasswordName """ - super(RegenerateCredentialParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3000,47 +2843,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - 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 location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -3049,7 +2886,7 @@ def __init__( self.system_data = None -class Registry(Resource): +class Registry(Resource): # pylint: disable=too-many-instance-attributes """An object that represents a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3062,14 +2899,14 @@ class Registry(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData - :ivar sku: Required. The SKU of the container registry. + :ivar sku: The SKU of the container registry. Required. :vartype sku: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Sku :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.IdentityProperties @@ -3078,8 +2915,8 @@ class Registry(Resource): :ivar creation_date: The creation date of the container registry in ISO8601 format. :vartype creation_date: ~datetime.datetime :ivar provisioning_state: The provisioning state of the container registry at the time the - operation was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", - "Failed", "Canceled". + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState :ivar status: The status of the container registry at the time the operation was called. @@ -3104,87 +2941,91 @@ class Registry(Resource): :vartype private_endpoint_connections: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.NetworkRuleBypassOptions :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. - Possible values include: "Enabled", "Disabled". + Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ZoneRedundancy - :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. It's in + preview and available in the Standard and Premium service tiers. :vartype anonymous_pull_enabled: bool """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'sku': {'required': True}, - 'login_server': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'data_endpoint_host_names': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'data_endpoint_host_names': {'key': 'properties.dataEndpointHostNames', 'type': '[str]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityProperties"] = None, - admin_user_enabled: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, - anonymous_pull_enabled: Optional[bool] = False, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword sku: Required. The SKU of the container registry. + :keyword sku: The SKU of the container registry. Required. :paramtype sku: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Sku :keyword identity: The identity of the container registry. :paramtype identity: @@ -3202,21 +3043,22 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.NetworkRuleBypassOptions :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ZoneRedundancy - :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. It's + in preview and available in the Standard and Premium service tiers. :paramtype anonymous_pull_enabled: bool """ - super(Registry, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.login_server = None @@ -3236,7 +3078,7 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryListCredentialsResult(msrest.serialization.Model): +class RegistryListCredentialsResult(_serialization.Model): """The response from the ListCredentials operation. :ivar username: The username for a container registry. @@ -3247,16 +3089,12 @@ class RegistryListCredentialsResult(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'passwords': {'key': 'passwords', 'type': '[RegistryPassword]'}, + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, } def __init__( - self, - *, - username: Optional[str] = None, - passwords: Optional[List["RegistryPassword"]] = None, - **kwargs + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs ): """ :keyword username: The username for a container registry. @@ -3265,12 +3103,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryPassword] """ - super(RegistryListCredentialsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.username = username self.passwords = passwords -class RegistryListResult(msrest.serialization.Model): +class RegistryListResult(_serialization.Model): """The result of a request to list container registries. :ivar value: The list of container registries. Since this list may be incomplete, the nextLink @@ -3281,17 +3119,11 @@ class RegistryListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Registry]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Registry"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. @@ -3299,53 +3131,48 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of container registries. :paramtype next_link: str """ - super(RegistryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegistryNameCheckRequest(msrest.serialization.Model): +class RegistryNameCheckRequest(_serialization.Model): """A request to check whether a container registry name is available. 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 name: Required. The name of the container registry. + :ivar name: The name of the container registry. Required. :vartype name: str :ivar type: The resource type of the container registry. This field must be set to - 'Microsoft.ContainerRegistry/registries'. Has constant value: + 'Microsoft.ContainerRegistry/registries'. Required. Default value is "Microsoft.ContainerRegistry/registries". :vartype type: str """ _validation = { - 'name': {'required': True, 'max_length': 50, 'min_length': 5, 'pattern': r'^[a-zA-Z0-9]*$'}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.ContainerRegistry/registries" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the container registry. + :keyword name: The name of the container registry. Required. :paramtype name: str """ - super(RegistryNameCheckRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class RegistryNameStatus(msrest.serialization.Model): +class RegistryNameStatus(_serialization.Model): """The result of a request to check the availability of a container registry name. :ivar name_available: The value that indicates whether the name is available. @@ -3358,9 +3185,9 @@ class RegistryNameStatus(msrest.serialization.Model): """ _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__( @@ -3380,50 +3207,46 @@ def __init__( name is not available. :paramtype message: str """ - super(RegistryNameStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class RegistryPassword(msrest.serialization.Model): +class RegistryPassword(_serialization.Model): """The login password for the container registry. - :ivar name: The password name. Possible values include: "password", "password2". + :ivar name: The password name. Known values are: "password" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PasswordName :ivar value: The password value. :vartype value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( - self, - *, - name: Optional[Union[str, "PasswordName"]] = None, - value: Optional[str] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs ): """ - :keyword name: The password name. Possible values include: "password", "password2". + :keyword name: The password name. Known values are: "password" and "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PasswordName :keyword value: The password value. :paramtype value: str """ - super(RegistryPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class RegistryUpdateParameters(msrest.serialization.Model): +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters for updating a container registry. :ivar identity: The identity of the container registry. :vartype identity: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.IdentityProperties - :ivar tags: A set of tags. The tags for the container registry. + :ivar tags: The tags for the container registry. :vartype tags: dict[str, str] :ivar sku: The SKU of the container registry. :vartype sku: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Sku @@ -3440,44 +3263,45 @@ class RegistryUpdateParameters(msrest.serialization.Model): :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. :vartype data_endpoint_enabled: bool :ivar public_network_access: Whether or not public network access is allowed for the container - registry. Possible values include: "Enabled", "Disabled". + registry. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PublicNetworkAccess :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network - restricted registry. Possible values include: "AzureServices", "None". + restricted registry. Known values are: "AzureServices" and "None". :vartype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.NetworkRuleBypassOptions - :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. It's in + preview and available in the Standard and Premium service tiers. :vartype anonymous_pull_enabled: bool """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, - 'policies': {'key': 'properties.policies', 'type': 'Policies'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperty'}, - 'data_endpoint_enabled': {'key': 'properties.dataEndpointEnabled', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'network_rule_bypass_options': {'key': 'properties.networkRuleBypassOptions', 'type': 'str'}, - 'anonymous_pull_enabled': {'key': 'properties.anonymousPullEnabled', 'type': 'bool'}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, } def __init__( self, *, - identity: Optional["IdentityProperties"] = None, + identity: Optional["_models.IdentityProperties"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, admin_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - policies: Optional["Policies"] = None, - encryption: Optional["EncryptionProperty"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, data_endpoint_enabled: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - network_rule_bypass_options: Optional[Union[str, "NetworkRuleBypassOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, anonymous_pull_enabled: Optional[bool] = None, **kwargs ): @@ -3485,7 +3309,7 @@ def __init__( :keyword identity: The identity of the container registry. :paramtype identity: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.IdentityProperties - :keyword tags: A set of tags. The tags for the container registry. + :keyword tags: The tags for the container registry. :paramtype tags: dict[str, str] :keyword sku: The SKU of the container registry. :paramtype sku: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Sku @@ -3502,17 +3326,18 @@ def __init__( :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. :paramtype data_endpoint_enabled: bool :keyword public_network_access: Whether or not public network access is allowed for the - container registry. Possible values include: "Enabled", "Disabled". + container registry. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PublicNetworkAccess :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a - network restricted registry. Possible values include: "AzureServices", "None". + network restricted registry. Known values are: "AzureServices" and "None". :paramtype network_rule_bypass_options: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.NetworkRuleBypassOptions - :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. It's + in preview and available in the Standard and Premium service tiers. :paramtype anonymous_pull_enabled: bool """ - super(RegistryUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.tags = tags self.sku = sku @@ -3526,25 +3351,25 @@ def __init__( self.anonymous_pull_enabled = anonymous_pull_enabled -class RegistryUsage(msrest.serialization.Model): +class RegistryUsage(_serialization.Model): """The quota usage for a container registry. :ivar name: The name of the usage. :vartype name: str :ivar limit: The limit of the usage. - :vartype limit: long + :vartype limit: int :ivar current_value: The current value of the usage. - :vartype current_value: long - :ivar unit: The unit of measurement. Possible values include: "Count", "Bytes". + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". :vartype unit: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUsageUnit """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -3553,28 +3378,28 @@ def __init__( name: Optional[str] = None, limit: Optional[int] = None, current_value: Optional[int] = None, - unit: Optional[Union[str, "RegistryUsageUnit"]] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, **kwargs ): """ :keyword name: The name of the usage. :paramtype name: str :keyword limit: The limit of the usage. - :paramtype limit: long + :paramtype limit: int :keyword current_value: The current value of the usage. - :paramtype current_value: long - :keyword unit: The unit of measurement. Possible values include: "Count", "Bytes". + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". :paramtype unit: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUsageUnit """ - super(RegistryUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.limit = limit self.current_value = current_value self.unit = unit -class RegistryUsageListResult(msrest.serialization.Model): +class RegistryUsageListResult(_serialization.Model): """The result of a request to get container registry quota usages. :ivar value: The list of container registry quota usages. @@ -3582,20 +3407,15 @@ class RegistryUsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistryUsage]'}, + "value": {"key": "value", "type": "[RegistryUsage]"}, } - def __init__( - self, - *, - value: Optional[List["RegistryUsage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): """ :keyword value: The list of container registry quota usages. :paramtype value: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUsage] """ - super(RegistryUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3612,15 +3432,15 @@ class Replication(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData :ivar provisioning_state: The provisioning state of the replication at the time the operation - was called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState @@ -3631,32 +3451,32 @@ class Replication(Resource): however its data will continue to be synced with other replications. :vartype region_endpoint_enabled: bool :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :vartype zone_redundancy: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ZoneRedundancy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, - 'zone_redundancy': {'key': 'properties.zoneRedundancy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, } def __init__( @@ -3664,33 +3484,33 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = True, - zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry - replication. Possible values include: "Enabled", "Disabled". + replication. Known values are: "Enabled" and "Disabled". :paramtype zone_redundancy: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ZoneRedundancy """ - super(Replication, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.status = None self.region_endpoint_enabled = region_endpoint_enabled self.zone_redundancy = zone_redundancy -class ReplicationListResult(msrest.serialization.Model): +class ReplicationListResult(_serialization.Model): """The result of a request to list replications for a container registry. :ivar value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3701,16 +3521,12 @@ class ReplicationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Replication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Replication"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of replications. Since this list may be incomplete, the nextLink field @@ -3719,15 +3535,15 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of replications. :paramtype next_link: str """ - super(ReplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ReplicationUpdateParameters(msrest.serialization.Model): +class ReplicationUpdateParameters(_serialization.Model): """The parameters for updating a replication. - :ivar tags: A set of tags. The tags for the replication. + :ivar tags: The tags for the replication. :vartype tags: dict[str, str] :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, @@ -3736,31 +3552,27 @@ class ReplicationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'region_endpoint_enabled': {'key': 'properties.regionEndpointEnabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: Optional[bool] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the replication. + :keyword tags: The tags for the replication. :paramtype tags: dict[str, str] :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. :paramtype region_endpoint_enabled: bool """ - super(ReplicationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.region_endpoint_enabled = region_endpoint_enabled -class Request(msrest.serialization.Model): +class Request(_serialization.Model): """The request that generated the event. :ivar id: The ID of the request that initiated the event. @@ -3778,17 +3590,17 @@ class Request(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'addr': {'key': 'addr', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'useragent': {'key': 'useragent', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin addr: Optional[str] = None, host: Optional[str] = None, method: Optional[str] = None, @@ -3809,7 +3621,7 @@ def __init__( :keyword useragent: The user agent header of the request. :paramtype useragent: str """ - super(Request, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.addr = addr self.host = host @@ -3817,7 +3629,7 @@ def __init__( self.useragent = useragent -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """The retention policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -3826,36 +3638,30 @@ class RetentionPolicy(msrest.serialization.Model): :vartype days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'days': {'key': 'days', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs - ): + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): """ :keyword days: The number of days to retain an untagged manifest after which it gets purged. :paramtype days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.days = days self.last_updated_time = None self.status = status @@ -3880,8 +3686,8 @@ class ScopeMap(ProxyResource): :vartype type_properties_type: str :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState :ivar actions: The list of scoped permissions for registry artifacts. @@ -3891,34 +3697,28 @@ class ScopeMap(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'type_properties_type': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'actions': {'key': 'properties.actions', '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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -3927,7 +3727,7 @@ def __init__( repositories/repository-name/metadata/write. :paramtype actions: list[str] """ - super(ScopeMap, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.type_properties_type = None self.creation_date = None @@ -3935,7 +3735,7 @@ def __init__( self.actions = actions -class ScopeMapListResult(msrest.serialization.Model): +class ScopeMapListResult(_serialization.Model): """The result of a request to list scope maps for a container registry. :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field @@ -3946,17 +3746,11 @@ class ScopeMapListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopeMap]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ScopeMap"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. @@ -3964,12 +3758,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of scope maps. :paramtype next_link: str """ - super(ScopeMapListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ScopeMapUpdateParameters(msrest.serialization.Model): +class ScopeMapUpdateParameters(_serialization.Model): """The properties for updating the scope map. :ivar description: The user friendly description of the scope map. @@ -3981,17 +3775,11 @@ class ScopeMapUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } - def __init__( - self, - *, - description: Optional[str] = None, - actions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): """ :keyword description: The user friendly description of the scope map. :paramtype description: str @@ -4000,53 +3788,48 @@ def __init__( repositories/repository-name/delete. :paramtype actions: list[str] """ - super(ScopeMapUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.actions = actions -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of a container registry. 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 name: Required. The SKU name of the container registry. Required for registry creation. - Possible values include: "Classic", "Basic", "Standard", "Premium". + :ivar name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SkuName - :ivar tier: The SKU tier based on the SKU name. Possible values include: "Classic", "Basic", - "Standard", "Premium". + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name of the container registry. Required for registry - creation. Possible values include: "Classic", "Basic", "Standard", "Premium". + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SoftDeletePolicy(msrest.serialization.Model): +class SoftDeletePolicy(_serialization.Model): """The soft delete policy for a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4056,43 +3839,39 @@ class SoftDeletePolicy(msrest.serialization.Model): :vartype retention_days: int :ivar last_updated_time: The timestamp when the policy was last updated. :vartype last_updated_time: ~datetime.datetime - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'retention_days': {'key': 'retentionDays', 'type': 'int'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, + "retention_days": {"key": "retentionDays", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, } def __init__( - self, - *, - retention_days: Optional[int] = 7, - status: Optional[Union[str, "PolicyStatus"]] = None, - **kwargs + self, *, retention_days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ :keyword retention_days: The number of days after which a soft-deleted item is permanently deleted. :paramtype retention_days: int - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ - super(SoftDeletePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.retention_days = retention_days self.last_updated_time = None self.status = status -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. :ivar addr: The IP or hostname and the port of the registry node that generated the event. @@ -4103,17 +3882,11 @@ class Source(msrest.serialization.Model): """ _attribute_map = { - 'addr': {'key': 'addr', 'type': 'str'}, - 'instance_id': {'key': 'instanceID', 'type': 'str'}, + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, } - def __init__( - self, - *, - addr: Optional[str] = None, - instance_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): """ :keyword addr: The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. @@ -4121,12 +3894,12 @@ def __init__( :keyword instance_id: The running instance of an application. Changes after each restart. :paramtype instance_id: str """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.addr = addr self.instance_id = instance_id -class Status(msrest.serialization.Model): +class Status(_serialization.Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when sending a request. @@ -4140,30 +3913,26 @@ class Status(msrest.serialization.Model): """ _validation = { - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'timestamp': {'readonly': True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Status, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None -class StatusDetailProperties(msrest.serialization.Model): +class StatusDetailProperties(_serialization.Model): """The status detail properties of the connected registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4181,28 +3950,24 @@ class StatusDetailProperties(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'code': {'readonly': True}, - 'description': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'correlation_id': {'readonly': True}, + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StatusDetailProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.code = None self.description = None @@ -4210,46 +3975,41 @@ def __init__( self.correlation_id = None -class StorageAccountProperties(msrest.serialization.Model): +class StorageAccountProperties(_serialization.Model): """The properties of a storage account for a container registry. Only applicable to Classic SKU. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The resource ID of the storage account. + :ivar id: The resource ID of the storage account. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. The resource ID of the storage account. + :keyword id: The resource ID of the storage account. Required. :paramtype id: str """ - super(StorageAccountProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SyncProperties(msrest.serialization.Model): +class SyncProperties(_serialization.Model): """The sync properties of the connected registry with its parent. 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 token_id: Required. The resource ID of the ACR token used to authenticate the connected - registry to its parent during sync. + :ivar token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. :vartype token_id: str :ivar schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4257,8 +4017,9 @@ class SyncProperties(msrest.serialization.Model): :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :vartype sync_window: ~datetime.timedelta - :ivar message_ttl: Required. The period of time for which a message is available to sync before - it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :vartype message_ttl: ~datetime.timedelta :ivar last_sync_time: The last time a sync occurred between the connected registry and its parent. @@ -4269,19 +4030,19 @@ class SyncProperties(msrest.serialization.Model): """ _validation = { - 'token_id': {'required': True}, - 'message_ttl': {'required': True}, - 'last_sync_time': {'readonly': True}, - 'gateway_endpoint': {'readonly': True}, + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'token_id': {'key': 'tokenId', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'gateway_endpoint': {'key': 'gatewayEndpoint', 'type': 'str'}, + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, } def __init__( @@ -4294,8 +4055,8 @@ def __init__( **kwargs ): """ - :keyword token_id: Required. The resource ID of the ACR token used to authenticate the - connected registry to its parent during sync. + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. :paramtype token_id: str :keyword schedule: The cron expression indicating the schedule that the connected registry will sync with its parent. @@ -4303,12 +4064,12 @@ def __init__( :keyword sync_window: The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype sync_window: ~datetime.timedelta - :keyword message_ttl: Required. The period of time for which a message is available to sync - before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per - ISO8601. + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.token_id = token_id self.schedule = schedule self.sync_window = sync_window @@ -4317,7 +4078,7 @@ def __init__( self.gateway_endpoint = None -class SyncUpdateProperties(msrest.serialization.Model): +class SyncUpdateProperties(_serialization.Model): """The parameters for updating the sync properties of the connected registry with its parent. :ivar schedule: The cron expression indicating the schedule that the connected registry will @@ -4332,9 +4093,9 @@ class SyncUpdateProperties(msrest.serialization.Model): """ _attribute_map = { - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'sync_window': {'key': 'syncWindow', 'type': 'duration'}, - 'message_ttl': {'key': 'messageTtl', 'type': 'duration'}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, } def __init__( @@ -4356,27 +4117,27 @@ def __init__( expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. :paramtype message_ttl: ~datetime.timedelta """ - super(SyncUpdateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.schedule = schedule self.sync_window = sync_window self.message_ttl = message_ttl -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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.LastModifiedByType :ivar last_modified_at: The timestamp of resource modification (UTC). @@ -4384,44 +4145,44 @@ class SystemData(msrest.serialization.Model): """ _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__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :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. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.LastModifiedByType :keyword last_modified_at: The timestamp of resource 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 @@ -4430,17 +4191,17 @@ def __init__( self.last_modified_at = last_modified_at -class Target(msrest.serialization.Model): +class Target(_serialization.Model): """The target of the event. :ivar media_type: The MIME type of the referenced object. :vartype media_type: str :ivar size: The number of bytes of the content. Same as Length field. - :vartype size: long + :vartype size: int :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :vartype digest: str :ivar length: The number of bytes of the content. Same as Size field. - :vartype length: long + :vartype length: int :ivar repository: The repository name. :vartype repository: str :ivar url: The direct URL to the content. @@ -4454,15 +4215,15 @@ class Target(msrest.serialization.Model): """ _attribute_map = { - 'media_type': {'key': 'mediaType', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'long'}, - 'digest': {'key': 'digest', 'type': 'str'}, - 'length': {'key': 'length', 'type': 'long'}, - 'repository': {'key': 'repository', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -4483,12 +4244,12 @@ def __init__( :keyword media_type: The MIME type of the referenced object. :paramtype media_type: str :keyword size: The number of bytes of the content. Same as Length field. - :paramtype size: long + :paramtype size: int :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. :paramtype digest: str :keyword length: The number of bytes of the content. Same as Size field. - :paramtype length: long + :paramtype length: int :keyword repository: The repository name. :paramtype repository: str :keyword url: The direct URL to the content. @@ -4500,7 +4261,7 @@ def __init__( :keyword version: The version of the artifact. :paramtype version: str """ - super(Target, self).__init__(**kwargs) + super().__init__(**kwargs) self.media_type = media_type self.size = size self.digest = digest @@ -4512,45 +4273,41 @@ def __init__( self.version = version -class TlsCertificateProperties(msrest.serialization.Model): +class TlsCertificateProperties(_serialization.Model): """The TLS certificate properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of certificate location. Possible values include: "LocalDirectory". + :ivar type: The type of certificate location. "LocalDirectory" :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.CertificateType :ivar location: Indicates the location of the certificates. :vartype location: str """ _validation = { - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsCertificateProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.location = None -class TlsProperties(msrest.serialization.Model): +class TlsProperties(_serialization.Model): """The TLS properties of the connected registry login server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Indicates whether HTTPS is enabled for the login server. Possible values include: - "Enabled", "Disabled". + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TlsStatus :ivar certificate: The certificate used to configure HTTPS for the login server. :vartype certificate: @@ -4558,22 +4315,18 @@ class TlsProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'certificate': {'readonly': True}, + "status": {"readonly": True}, + "certificate": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'TlsCertificateProperties'}, + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TlsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.certificate = None @@ -4593,8 +4346,8 @@ class Token(ProxyResource): :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData :ivar creation_date: The creation date of scope map. :vartype creation_date: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState :ivar scope_map_id: The resource ID of the scope map to which the token will be associated @@ -4603,38 +4356,38 @@ class Token(ProxyResource): :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenCredentialsProperties - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - credentials: Optional["TokenCredentialsProperties"] = None, - status: Optional[Union[str, "TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, **kwargs ): """ @@ -4644,11 +4397,11 @@ def __init__( :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenCredentialsProperties - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenStatus """ - super(Token, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_date = None self.provisioning_state = None self.scope_map_id = scope_map_id @@ -4656,10 +4409,10 @@ def __init__( self.status = status -class TokenCertificate(msrest.serialization.Model): +class TokenCertificate(_serialization.Model): """The properties of a certificate used for authenticating a token. - :ivar name: Possible values include: "certificate1", "certificate2". + :ivar name: Known values are: "certificate1" and "certificate2". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenCertificateName :ivar expiry: The expiry datetime of the certificate. @@ -4672,23 +4425,23 @@ class TokenCertificate(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "TokenCertificateName"]] = None, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, expiry: Optional[datetime.datetime] = None, thumbprint: Optional[str] = None, encoded_pem_certificate: Optional[str] = None, **kwargs ): """ - :keyword name: Possible values include: "certificate1", "certificate2". + :keyword name: Known values are: "certificate1" and "certificate2". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenCertificateName :keyword expiry: The expiry datetime of the certificate. @@ -4699,14 +4452,14 @@ def __init__( format that will be used for authenticating the token. :paramtype encoded_pem_certificate: str """ - super(TokenCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.expiry = expiry self.thumbprint = thumbprint self.encoded_pem_certificate = encoded_pem_certificate -class TokenCredentialsProperties(msrest.serialization.Model): +class TokenCredentialsProperties(_serialization.Model): """The properties of the credentials that can be used for authenticating the token. :ivar certificates: @@ -4718,15 +4471,15 @@ class TokenCredentialsProperties(msrest.serialization.Model): """ _attribute_map = { - 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, - 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, } def __init__( self, *, - certificates: Optional[List["TokenCertificate"]] = None, - passwords: Optional[List["TokenPassword"]] = None, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs ): """ @@ -4737,12 +4490,12 @@ def __init__( :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPassword] """ - super(TokenCredentialsProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificates = certificates self.passwords = passwords -class TokenListResult(msrest.serialization.Model): +class TokenListResult(_serialization.Model): """The result of a request to list tokens for a container registry. :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should @@ -4753,17 +4506,11 @@ class TokenListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Token]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Token"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. @@ -4771,12 +4518,12 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of tokens. :paramtype next_link: str """ - super(TokenListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TokenPassword(msrest.serialization.Model): +class TokenPassword(_serialization.Model): """The password that will be used for authenticating the token of a container registry. Variables are only populated by the server, and will be ignored when sending a request. @@ -4785,7 +4532,7 @@ class TokenPassword(msrest.serialization.Model): :vartype creation_time: ~datetime.datetime :ivar expiry: The expiry datetime of the password. :vartype expiry: ~datetime.datetime - :ivar name: The password name "password1" or "password2". Possible values include: "password1", + :ivar name: The password name "password1" or "password2". Known values are: "password1" and "password2". :vartype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPasswordName @@ -4794,14 +4541,14 @@ class TokenPassword(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } def __init__( @@ -4809,7 +4556,7 @@ def __init__( *, creation_time: Optional[datetime.datetime] = None, expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "TokenPasswordName"]] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, **kwargs ): """ @@ -4817,26 +4564,26 @@ def __init__( :paramtype creation_time: ~datetime.datetime :keyword expiry: The expiry datetime of the password. :paramtype expiry: ~datetime.datetime - :keyword name: The password name "password1" or "password2". Possible values include: - "password1", "password2". + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". :paramtype name: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenPasswordName """ - super(TokenPassword, self).__init__(**kwargs) + super().__init__(**kwargs) self.creation_time = creation_time self.expiry = expiry self.name = name self.value = None -class TokenUpdateParameters(msrest.serialization.Model): +class TokenUpdateParameters(_serialization.Model): """The parameters for updating a token. :ivar scope_map_id: The resource ID of the scope map to which the token will be associated with. :vartype scope_map_id: str - :ivar status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenStatus :ivar credentials: The credentials that can be used for authenticating the token. :vartype credentials: @@ -4844,74 +4591,72 @@ class TokenUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, } def __init__( self, *, scope_map_id: Optional[str] = None, - status: Optional[Union[str, "TokenStatus"]] = None, - credentials: Optional["TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, **kwargs ): """ :keyword scope_map_id: The resource ID of the scope map to which the token will be associated with. :paramtype scope_map_id: str - :keyword status: The status of the token example enabled or disabled. Possible values include: - "enabled", "disabled". + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenStatus :keyword credentials: The credentials that can be used for authenticating the token. :paramtype credentials: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenCredentialsProperties """ - super(TokenUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope_map_id = scope_map_id self.status = status self.credentials = credentials -class TrustPolicy(msrest.serialization.Model): +class TrustPolicy(_serialization.Model): """The content trust policy for a container registry. - :ivar type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :ivar type: The type of trust policy. "Notary" :vartype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TrustPolicyType - :ivar status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "TrustPolicyType"]] = "Notary", - status: Optional[Union[str, "PolicyStatus"]] = None, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs ): """ - :keyword type: The type of trust policy. Possible values include: "Notary". Default value: - "Notary". + :keyword type: The type of trust policy. "Notary" :paramtype type: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TrustPolicyType - :keyword status: The value that indicates whether the policy is enabled or not. Possible values - include: "enabled", "disabled". + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PolicyStatus """ - super(TrustPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.status = status -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """UserIdentityProperties. :ivar principal_id: The principal id of user assigned identity. @@ -4921,24 +4666,18 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id @@ -4956,15 +4695,15 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :ivar location: Required. The location of the resource. This cannot be changed after the - resource is created. + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.SystemData - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -4974,32 +4713,32 @@ class Webhook(Resource): :vartype actions: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookAction] :ivar provisioning_state: The provisioning state of the webhook at the time the operation was - called. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5007,19 +4746,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword location: Required. The location of the resource. This cannot be changed after the - resource is created. + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5030,29 +4769,29 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookAction] """ - super(Webhook, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.status = status self.scope = scope self.actions = actions self.provisioning_state = None -class WebhookCreateParameters(msrest.serialization.Model): +class WebhookCreateParameters(_serialization.Model): """The parameters for creating a webhook. All required parameters must be populated in order to send to Azure. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] - :ivar location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. :vartype location: str :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -5064,17 +4803,17 @@ class WebhookCreateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5084,23 +4823,23 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] - :keyword location: Required. The location of the webhook. This cannot be changed after the - resource is created. + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. :paramtype location: str :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5111,7 +4850,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookAction] """ - super(WebhookCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.service_uri = service_uri @@ -5121,7 +4860,7 @@ def __init__( self.actions = actions -class WebhookListResult(msrest.serialization.Model): +class WebhookListResult(_serialization.Model): """The result of a request to list webhooks for a container registry. :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should @@ -5132,17 +4871,11 @@ class WebhookListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Webhook"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. @@ -5150,22 +4883,22 @@ def __init__( :keyword next_link: The URI that can be used to request the next list of webhooks. :paramtype next_link: str """ - super(WebhookListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class WebhookUpdateParameters(msrest.serialization.Model): +class WebhookUpdateParameters(_serialization.Model): """The parameters for updating a webhook. - :ivar tags: A set of tags. The tags for the webhook. + :ivar tags: The tags for the webhook. :vartype tags: dict[str, str] :ivar service_uri: The service URI for the webhook to post notifications. :vartype service_uri: str :ivar custom_headers: Custom headers that will be added to the webhook notifications. :vartype custom_headers: dict[str, str] - :ivar status: The status of the webhook at the time the operation was called. Possible values - include: "enabled", "disabled". + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". :vartype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. @@ -5177,12 +4910,12 @@ class WebhookUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'service_uri': {'key': 'properties.serviceUri', 'type': 'str'}, - 'custom_headers': {'key': 'properties.customHeaders', 'type': '{str}'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'actions': {'key': 'properties.actions', 'type': '[str]'}, + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, } def __init__( @@ -5191,20 +4924,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, service_uri: Optional[str] = None, custom_headers: Optional[Dict[str, str]] = None, - status: Optional[Union[str, "WebhookStatus"]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, scope: Optional[str] = None, - actions: Optional[List[Union[str, "WebhookAction"]]] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, **kwargs ): """ - :keyword tags: A set of tags. The tags for the webhook. + :keyword tags: The tags for the webhook. :paramtype tags: dict[str, str] :keyword service_uri: The service URI for the webhook to post notifications. :paramtype service_uri: str :keyword custom_headers: Custom headers that will be added to the webhook notifications. :paramtype custom_headers: dict[str, str] - :keyword status: The status of the webhook at the time the operation was called. Possible - values include: "enabled", "disabled". + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". :paramtype status: str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookStatus :keyword scope: The scope of repositories where the event can be triggered. For example, @@ -5215,7 +4948,7 @@ def __init__( :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookAction] """ - super(WebhookUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.service_uri = service_uri self.custom_headers = custom_headers diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/__init__.py index 532500a8b984..8ff8c9ba50a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/__init__.py @@ -18,16 +18,22 @@ from ._tokens_operations import TokensOperations from ._webhooks_operations import WebhooksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectedRegistriesOperations', - 'ExportPipelinesOperations', - 'RegistriesOperations', - 'ImportPipelinesOperations', - 'Operations', - 'PipelineRunsOperations', - 'PrivateEndpointConnectionsOperations', - 'ReplicationsOperations', - 'ScopeMapsOperations', - 'TokensOperations', - 'WebhooksOperations', + "ConnectedRegistriesOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_connected_registries_operations.py index c6d5e0a4ee06..c8dbee477b72 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_connected_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_connected_registries_operations.py @@ -6,310 +6,330 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - connected_registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_deactivate_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "connectedRegistryName": _SERIALIZER.url("connected_registry_name", connected_registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ConnectedRegistriesOperations(object): - """ConnectedRegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ConnectedRegistryListResult"]: + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: """Lists all connected registries for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param filter: An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource id of the @@ -317,42 +337,55 @@ def list( value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectedRegistryListResult or the result of - cls(response) + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - filter=filter, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -363,16 +396,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -383,59 +414,63 @@ 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.ContainerRegistry/registries/{registryName}/connectedRegistries"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any - ) -> "_models.ConnectedRegistry": + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: """Gets the properties of the connected registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectedRegistry, or the result of cls(response) + :return: ConnectedRegistry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,72 +478,174 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(connected_registry_create_parameters, 'ConnectedRegistry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -516,21 +653,25 @@ def begin_create( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_create_parameters: "_models.ConnectedRegistry", + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Creates a connected registry for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry 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 @@ -543,17 +684,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -562,93 +705,100 @@ def begin_create( connected_registry_create_parameters=connected_registry_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a connected registry from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -660,102 +810,211 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.ConnectedRegistry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] + ) -> _models.ConnectedRegistry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(connected_registry_update_parameters, 'ConnectedRegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -763,21 +1022,26 @@ def begin_update( resource_group_name: str, registry_name: str, connected_registry_name: str, - connected_registry_update_parameters: "_models.ConnectedRegistryUpdateParameters", + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ConnectedRegistry"]: + ) -> LROPoller[_models.ConnectedRegistry]: """Updates a connected registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_name: str :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistryUpdateParameters 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 @@ -790,17 +1054,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ConnectedRegistry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectedRegistry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -809,93 +1075,100 @@ def begin_update( connected_registry_update_parameters=connected_registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ConnectedRegistry', pipeline_response) + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } def _deactivate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deactivate_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deactivate_initial.metadata['url'], + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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, {}) - _deactivate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore - + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } @distributed_trace - def begin_deactivate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - **kwargs: Any + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any ) -> LROPoller[None]: """Deactivates the connected registry instance. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param connected_registry_name: The name of the connected registry. + :param connected_registry_name: The name of the connected registry. Required. :type connected_registry_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. @@ -907,42 +1180,50 @@ def begin_deactivate( # 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deactivate_initial( + raw_result = self._deactivate_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, connected_registry_name=connected_registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate"} # type: ignore + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_export_pipelines_operations.py index 5f6fe9bb14f1..7071cd8f0d7c 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_export_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_export_pipelines_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "exportPipelineName": _SERIALIZER.url("export_pipeline_name", export_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ExportPipelinesOperations(object): - """ExportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ExportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: """Lists all export pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ExportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/exportPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any - ) -> "_models.ExportPipeline": + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: """Gets the properties of the export pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExportPipeline, or the result of cls(response) + :return: ExportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,94 +364,119 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], **kwargs: Any - ) -> "_models.ExportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] + ) -> _models.ExportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(export_pipeline_create_parameters, 'ExportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, export_pipeline_name: str, - export_pipeline_create_parameters: "_models.ExportPipeline", + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ExportPipeline"]: + ) -> LROPoller[_models.ExportPipeline]: """Creates an export pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_name: str :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. :type export_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline + :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 @@ -447,17 +489,100 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +591,100 @@ def begin_create( export_pipeline_create_parameters=export_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ExportPipeline', pipeline_response) + deserialized = self._deserialize("ExportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an export pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param export_pipeline_name: The name of the export pipeline. + :param export_pipeline_name: The name of the export pipeline. Required. :type export_pipeline_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. @@ -564,42 +696,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, export_pipeline_name=export_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_import_pipelines_operations.py index eaad555e107b..dcf8177a0ce6 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_import_pipelines_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_import_pipelines_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "importPipelineName": _SERIALIZER.url("import_pipeline_name", import_pipeline_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ImportPipelinesOperations(object): - """ImportPipelinesOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ImportPipelineListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: """Lists all import pipelines for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ImportPipelineListResult or the result of - cls(response) + :return: An iterator like instance of either ImportPipeline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipelineListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipelineListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/importPipelines"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any - ) -> "_models.ImportPipeline": + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: """Gets the properties of the import pipeline. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImportPipeline, or the result of cls(response) + :return: ImportPipeline or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,94 +364,119 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], **kwargs: Any - ) -> "_models.ImportPipeline": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] + ) -> _models.ImportPipeline: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(import_pipeline_create_parameters, 'ImportPipeline') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, import_pipeline_name: str, - import_pipeline_create_parameters: "_models.ImportPipeline", + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ImportPipeline"]: + ) -> LROPoller[_models.ImportPipeline]: """Creates an import pipeline for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_name: str :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. :type import_pipeline_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline + :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 @@ -447,17 +489,100 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImportPipeline"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +591,100 @@ def begin_create( import_pipeline_create_parameters=import_pipeline_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ImportPipeline', pipeline_response) + deserialized = self._deserialize("ImportPipeline", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an import pipeline from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param import_pipeline_name: The name of the import pipeline. + :param import_pipeline_name: The name of the import pipeline. Required. :type import_pipeline_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. @@ -564,42 +696,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, import_pipeline_name=import_pipeline_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_operations.py index 3d2025b8fa86..10c48db51da3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_operations.py @@ -6,108 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - accept = "application/json" +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: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: """Lists all of the available Azure Container Registry REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either OperationDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -118,16 +141,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.ContainerRegistry/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_pipeline_runs_operations.py index 71c43cd5d8cc..938a5f40b25d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_pipeline_runs_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_pipeline_runs_operations.py @@ -6,257 +6,272 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "pipelineRunName": _SERIALIZER.url("pipeline_run_name", pipeline_run_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class PipelineRunsOperations(object): - """PipelineRunsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PipelineRunListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: """Lists all the pipeline runs for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PipelineRunListResult or the result of - cls(response) + :return: An iterator like instance of either PipelineRun or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRunListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRunListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -267,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PipelineRunListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,59 +300,63 @@ 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.ContainerRegistry/registries/{registryName}/pipelineRuns"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any - ) -> "_models.PipelineRun": + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: """Gets the detailed information for a given pipeline run. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PipelineRun, or the result of cls(response) + :return: PipelineRun or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,72 +364,172 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> "_models.PipelineRun": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] + ) -> _models.PipelineRun: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(pipeline_run_create_parameters, 'PipelineRun') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -420,21 +537,25 @@ def begin_create( resource_group_name: str, registry_name: str, pipeline_run_name: str, - pipeline_run_create_parameters: "_models.PipelineRun", + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], **kwargs: Any - ) -> LROPoller["_models.PipelineRun"]: + ) -> LROPoller[_models.PipelineRun]: """Creates a pipeline run for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_name: str - :param pipeline_run_create_parameters: The parameters for creating a pipeline run. + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun 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 @@ -447,17 +568,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PipelineRun] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PipelineRun"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -466,93 +589,100 @@ def begin_create( pipeline_run_create_parameters=pipeline_run_create_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 = pipeline_response.http_response - deserialized = self._deserialize('PipelineRun', pipeline_response) + deserialized = self._deserialize("PipelineRun", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a pipeline run from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param pipeline_run_name: The name of the pipeline run. + :param pipeline_run_name: The name of the pipeline run. Required. :type pipeline_run_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. @@ -564,42 +694,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, pipeline_run_name=pipeline_run_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_private_endpoint_connections_operations.py index 9ae301530ea5..710e628031ed 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,251 +6,281 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, + +def build_create_or_update_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all private endpoint connections in a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -261,16 +291,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -280,112 +308,133 @@ 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,18 +442,104 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_02_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -412,22 +547,26 @@ def begin_create_or_update( resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection + ~azure.mgmt.containerregistry.v2022_02_01_preview.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 :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 @@ -440,17 +579,19 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -459,65 +600,74 @@ def begin_create_or_update( private_endpoint_connection=private_endpoint_connection, 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 = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -527,25 +677,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_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. @@ -557,42 +704,50 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, private_endpoint_connection_name=private_endpoint_connection_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_registries_operations.py index 7bba43cd7f32..007d5bbfce36 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_registries_operations.py @@ -6,621 +6,592 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_import_image_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_link_resource_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_credential_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) -def build_generate_credentials_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 RegistriesOperations(object): - """RegistriesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _import_image_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'ImportImageParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_import_image_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._import_image_initial.metadata['url'], + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -630,28 +601,105 @@ def _import_image_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _import_image_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( # pylint: disable=inconsistent-return-statements + def begin_import_image( self, resource_group_name: str, registry_name: str, - parameters: "_models.ImportImageParameters", + parameters: Union[_models.ImportImageParameters, IO], **kwargs: Any ) -> LROPoller[None]: """Copies an image to this container registry from the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param parameters: The parameters specifying the image to copy and the source container - registry. + registry. Is either a model type or a IO type. Required. :type parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ImportImageParameters 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 @@ -662,145 +710,228 @@ def begin_import_image( # 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_image_initial( + raw_result = self._import_image_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, 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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_import_image.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage"} # type: ignore + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } - @distributed_trace + @overload def check_name_availability( self, - registry_name_check_request: "_models.RegistryNameCheckRequest", + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.RegistryNameStatus": + ) -> _models.RegistryNameStatus: """Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally unique, and between 5 and 50 characters in length. :param registry_name_check_request: The object containing information for the availability - request. + request. Required. :type registry_name_check_request: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus, or the result of cls(response) + :return: RegistryNameStatus or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryNameStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryNameStatus"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_name_check_request, 'RegistryNameCheckRequest') + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") request = build_check_name_availability_request( 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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryNameStatus', pipeline_response) + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -811,16 +942,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,55 +959,65 @@ 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}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.RegistryListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: """Lists all the container registries under the specified resource group. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. 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 RegistryListResult or the result of cls(response) + :return: An iterator like instance of either Registry or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_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_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -889,16 +1028,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RegistryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -908,106 +1045,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.Registry": + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: """Gets the properties of the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Registry, or the result of cls(response) + :return: Registry or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry: "_models.Registry", - **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(registry, 'Registry') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1015,36 +1168,109 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + return deserialized # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } - @distributed_trace + @overload def begin_create( self, resource_group_name: str, registry_name: str, - registry: "_models.Registry", + registry: _models.Registry, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Creates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry: The parameters for creating a container registry. + :param registry: The parameters for creating a container registry. Required. :type registry: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry 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 @@ -1056,17 +1282,19 @@ def begin_create( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -1074,63 +1302,73 @@ def begin_create( registry=registry, 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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1140,22 +1378,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_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. @@ -1167,80 +1401,104 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> "_models.Registry": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] + ) -> _models.Registry: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(registry_update_parameters, 'RegistryUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1248,37 +1506,115 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, registry_name: str, - registry_update_parameters: "_models.RegistryUpdateParameters", + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Registry"]: + ) -> LROPoller[_models.Registry]: """Updates a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param registry_update_parameters: The parameters for updating a container registry. + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUpdateParameters 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 @@ -1290,17 +1626,19 @@ def begin_update( :return: An instance of LROPoller that returns either Registry or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Registry] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Registry"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -1308,141 +1646,163 @@ def begin_update( registry_update_parameters=registry_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Registry', pipeline_response) + deserialized = self._deserialize("Registry", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } @distributed_trace def list_usages( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryUsageListResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: """Gets the quota usages for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryUsageListResult, or the result of cls(response) + :return: RegistryUsageListResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryUsageListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) - request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_usages.metadata['url'], + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryUsageListResult', pipeline_response) + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages"} # type: ignore - + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Lists the private link resources for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_private_link_resources.metadata['url'], + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1453,16 +1813,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1472,59 +1830,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources"} # type: ignore + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } @distributed_trace def get_private_link_resource( - self, - resource_group_name: str, - registry_name: str, - group_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets a private link resource by a specified group name for a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_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.containerregistry.v2022_02_01_preview.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_private_link_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_private_link_resource.metadata['url'], + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1532,214 +1894,397 @@ def get_private_link_resource( 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_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}"} # type: ignore - + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: """Lists the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials"} # type: ignore + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_credential( self, resource_group_name: str, registry_name: str, - regenerate_credential_parameters: "_models.RegenerateCredentialParameters", + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], **kwargs: Any - ) -> "_models.RegistryListCredentialsResult": + ) -> _models.RegistryListCredentialsResult: """Regenerates one of the login credentials for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :param regenerate_credential_parameters: Specifies name of the password which should be - regenerated -- password or password2. + regenerated -- password or password2. Is either a model type or a IO type. Required. :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult, or the result of cls(response) + :return: RegistryListCredentialsResult or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.RegistryListCredentialsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistryListCredentialsResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) - _json = self._serialize.body(regenerate_credential_parameters, 'RegenerateCredentialParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") request = build_regenerate_credential_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_credential.metadata['url'], + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RegistryListCredentialsResult', pipeline_response) + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_credential.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential"} # type: ignore - + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } def _generate_credentials_initial( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> Optional["_models.GenerateCredentialsResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateCredentialsResult"]] + ) -> Optional[_models.GenerateCredentialsResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') - - request = build_generate_credentials_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( resource_group_name=resource_group_name, registry_name=registry_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._generate_credentials_initial.metadata['url'], + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _generate_credentials_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_generate_credentials( self, resource_group_name: str, registry_name: str, - generate_credentials_parameters: "_models.GenerateCredentialsParameters", + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], **kwargs: Any - ) -> LROPoller["_models.GenerateCredentialsResult"]: + ) -> LROPoller[_models.GenerateCredentialsResult]: """Generate keys for a token of a specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param generate_credentials_parameters: The parameters for generating credentials. + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsParameters 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 @@ -1752,17 +2297,19 @@ def begin_generate_credentials( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.GenerateCredentialsResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCredentialsResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._generate_credentials_initial( resource_group_name=resource_group_name, @@ -1770,29 +2317,34 @@ def begin_generate_credentials( generate_credentials_parameters=generate_credentials_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 = pipeline_response.http_response - deserialized = self._deserialize('GenerateCredentialsResult', pipeline_response) + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_generate_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials"} # type: ignore + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_replications_operations.py index 325dad88859e..8795686ae343 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_replications_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_replications_operations.py @@ -6,297 +6,307 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - replication_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - replication_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "replicationName": _SERIALIZER.url("replication_name", replication_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ReplicationsOperations(object): - """ReplicationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: """Lists all the replications for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationListResult or the result of - cls(response) + :return: An iterator like instance of either Replication or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -307,16 +317,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,112 +334,133 @@ 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.ContainerRegistry/registries/{registryName}/replications"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } @distributed_trace def get( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any - ) -> "_models.Replication": + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: """Gets the properties of the specified replication. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replication, or the result of cls(response) + :return: Replication or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(replication, 'Replication') - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -439,18 +468,99 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -458,20 +568,24 @@ def begin_create( resource_group_name: str, registry_name: str, replication_name: str, - replication: "_models.Replication", + replication: Union[_models.Replication, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Creates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication: The parameters for creating a replication. - :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication 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 @@ -484,17 +598,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -503,65 +619,74 @@ def begin_create( replication=replication, 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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -571,25 +696,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a replication from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_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. @@ -601,83 +723,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> "_models.Replication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] + ) -> _models.Replication: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(replication_update_parameters, 'ReplicationUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, replication_name=replication_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,18 +831,100 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -704,21 +932,25 @@ def begin_update( resource_group_name: str, registry_name: str, replication_name: str, - replication_update_parameters: "_models.ReplicationUpdateParameters", + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Replication"]: + ) -> LROPoller[_models.Replication]: """Updates a replication for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param replication_name: The name of the replication. + :param replication_name: The name of the replication. Required. :type replication_name: str - :param replication_update_parameters: The parameters for updating a replication. + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ReplicationUpdateParameters 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 @@ -731,17 +963,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Replication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -750,29 +984,34 @@ def begin_update( replication_update_parameters=replication_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Replication', pipeline_response) + deserialized = self._deserialize("Replication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_scope_maps_operations.py index e6a1694d9f82..f5d14abaca54 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_scope_maps_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_scope_maps_operations.py @@ -6,302 +6,313 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - scope_map_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - scope_map_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "scopeMapName": _SERIALIZER.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-_]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 ScopeMapsOperations(object): - """ScopeMapsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.ScopeMapListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: """Lists all the scope maps for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopeMapListResult or the result of cls(response) + :return: An iterator like instance of either ScopeMap or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMapListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -312,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopeMapListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,59 +341,61 @@ 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.ContainerRegistry/registries/{registryName}/scopeMaps"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any - ) -> "_models.ScopeMap": + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: """Gets the properties of the specified scope map. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopeMap, or the result of cls(response) + :return: ScopeMap or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,72 +403,170 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -465,21 +574,25 @@ def begin_create( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_create_parameters: "_models.ScopeMap", + scope_map_create_parameters: Union[_models.ScopeMap, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Creates a scope map for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_create_parameters: The parameters for creating a scope map. + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap 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 @@ -491,17 +604,19 @@ def begin_create( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -510,93 +625,100 @@ def begin_create( scope_map_create_parameters=scope_map_create_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a scope map from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_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. @@ -608,102 +730,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> "_models.ScopeMap": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] + ) -> _models.ScopeMap: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, scope_map_name=scope_map_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -711,21 +938,25 @@ def begin_update( resource_group_name: str, registry_name: str, scope_map_name: str, - scope_map_update_parameters: "_models.ScopeMapUpdateParameters", + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.ScopeMap"]: + ) -> LROPoller[_models.ScopeMap]: """Updates a scope map with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param scope_map_name: The name of the scope map. + :param scope_map_name: The name of the scope map. Required. :type scope_map_name: str - :param scope_map_update_parameters: The parameters for updating a scope map. + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMapUpdateParameters 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 @@ -737,17 +968,19 @@ def begin_update( :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.ScopeMap] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopeMap"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -756,29 +989,34 @@ def begin_update( scope_map_update_parameters=scope_map_update_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 = pipeline_response.http_response - deserialized = self._deserialize('ScopeMap', pipeline_response) + deserialized = self._deserialize("ScopeMap", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_tokens_operations.py index b970ccc2e2c5..f17296a277a3 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_tokens_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_tokens_operations.py @@ -6,302 +6,313 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - token_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - token_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "tokenName": _SERIALIZER.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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 TokensOperations(object): - """TokensOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.TokenListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: """Lists all the tokens for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TokenListResult or the result of cls(response) + :return: An iterator like instance of either Token or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TokenListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -312,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TokenListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,59 +341,61 @@ 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.ContainerRegistry/registries/{registryName}/tokens"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any - ) -> "_models.Token": + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: """Gets the properties of the specified token. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Token, or the result of cls(response) + :return: Token or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,72 +403,169 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_create_parameters, 'Token') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -465,20 +573,25 @@ def begin_create( resource_group_name: str, registry_name: str, token_name: str, - token_create_parameters: "_models.Token", + token_create_parameters: Union[_models.Token, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Creates a token for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_create_parameters: The parameters for creating a token. + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token + 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 @@ -490,17 +603,19 @@ def begin_create( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -509,93 +624,100 @@ def begin_create( token_create_parameters=token_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - token_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a token from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_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. @@ -607,102 +729,207 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> "_models.Token": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] + ) -> _models.Token: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, token_name=token_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -710,21 +937,25 @@ def begin_update( resource_group_name: str, registry_name: str, token_name: str, - token_update_parameters: "_models.TokenUpdateParameters", + token_update_parameters: Union[_models.TokenUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Token"]: + ) -> LROPoller[_models.Token]: """Updates a token with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param token_name: The name of the token. + :param token_name: The name of the token. Required. :type token_name: str - :param token_update_parameters: The parameters for updating a token. + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. :type token_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.TokenUpdateParameters 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 @@ -736,17 +967,19 @@ def begin_update( :return: An instance of LROPoller that returns either Token or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Token] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Token"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -755,29 +988,34 @@ def begin_update( token_update_parameters=token_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Token', pipeline_response) + deserialized = self._deserialize("Token", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_webhooks_operations.py index ffd4e8316190..793433086037 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_webhooks_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_02_01_preview/operations/_webhooks_operations.py @@ -6,410 +6,421 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat 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') -JSONType = Any + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _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, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - 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) def build_ping_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_events_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_callback_config_request( - subscription_id: str, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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', min_length=1), - "registryName": _SERIALIZER.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), - "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class WebhooksOperations(object): - """WebhooksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerregistry.v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_02_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - **kwargs: Any - ) -> Iterable["_models.WebhookListResult"]: + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: """Lists all the webhooks for the specified container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WebhookListResult or the result of cls(response) + :return: An iterator like instance of either Webhook or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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, registry_name=registry_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -420,16 +431,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,112 +448,131 @@ 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.ContainerRegistry/registries/{registryName}/webhooks"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.Webhook": + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: """Gets the properties of the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Webhook, or the result of cls(response) + :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _create_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(webhook_create_parameters, 'WebhookCreateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,18 +580,98 @@ def _create_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -571,21 +679,25 @@ def begin_create( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_create_parameters: "_models.WebhookCreateParameters", + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Creates a webhook for a container registry with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_create_parameters: The parameters for creating a webhook. + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookCreateParameters 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 @@ -597,17 +709,19 @@ def begin_create( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -616,65 +730,74 @@ def begin_create( webhook_create_parameters=webhook_create_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -684,25 +807,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a webhook from a container registry. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_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. @@ -714,83 +834,107 @@ 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: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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 = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } def _update_initial( self, resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> "_models.Webhook": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] + ) -> _models.Webhook: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(webhook_update_parameters, 'WebhookUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_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, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -798,18 +942,98 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group to which the container registry + belongs. Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -817,21 +1041,25 @@ def begin_update( resource_group_name: str, registry_name: str, webhook_name: str, - webhook_update_parameters: "_models.WebhookUpdateParameters", + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Webhook"]: + ) -> LROPoller[_models.Webhook]: """Updates a webhook with the specified parameters. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str - :param webhook_update_parameters: The parameters for updating a webhook. + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters + ~azure.mgmt.containerregistry.v2022_02_01_preview.models.WebhookUpdateParameters 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 @@ -843,17 +1071,19 @@ def begin_update( :return: An instance of LROPoller that returns either Webhook or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Webhook] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -862,149 +1092,167 @@ def begin_update( webhook_update_parameters=webhook_update_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 = pipeline_response.http_response - deserialized = self._deserialize('Webhook', pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } @distributed_trace - def ping( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.EventInfo": + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: """Triggers a ping event to be sent to the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventInfo, or the result of cls(response) + :return: EventInfo or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.EventInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) - request = build_ping_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.ping.metadata['url'], + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventInfo', pipeline_response) + deserialized = self._deserialize("EventInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - ping.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping"} # type: ignore - + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } @distributed_trace def list_events( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> Iterable["_models.EventListResult"]: + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: """Lists recent events for the specified webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventListResult or the result of cls(response) + :return: An iterator like instance of either Event or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.EventListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_02_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_events_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_events.metadata['url'], + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: - - request = build_list_events_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - registry_name=registry_name, - webhook_name=webhook_name, - api_version=api_version, - template_url=next_link, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -1015,16 +1263,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1034,71 +1280,76 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_events.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents"} # type: ignore + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } @distributed_trace def get_callback_config( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - **kwargs: Any - ) -> "_models.CallbackConfig": + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: """Gets the configuration of service URI and custom headers for the webhook. :param resource_group_name: The name of the resource group to which the container registry - belongs. + belongs. Required. :type resource_group_name: str - :param registry_name: The name of the container registry. + :param registry_name: The name of the container registry. Required. :type registry_name: str - :param webhook_name: The name of the webhook. + :param webhook_name: The name of the webhook. Required. :type webhook_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CallbackConfig, or the result of cls(response) + :return: CallbackConfig or the result of cls(response) :rtype: ~azure.mgmt.containerregistry.v2022_02_01_preview.models.CallbackConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CallbackConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01-preview") # type: str + api_version: Literal["2022-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-02-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) - request = build_get_callback_config_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, registry_name=registry_name, webhook_name=webhook_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_callback_config.metadata['url'], + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CallbackConfig', pipeline_response) + deserialized = self._deserialize("CallbackConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_callback_config.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig"} # type: ignore - + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/__init__.py new file mode 100644 index 000000000000..0e99a7bac3b7 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._container_registry_management_client import ContainerRegistryManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_configuration.py new file mode 100644 index 000000000000..a1ed6c2a3535 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ContainerRegistryManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-containerregistry/{}".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.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 + ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_container_registry_management_client.py new file mode 100644 index 000000000000..ab6d63e08e2c --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_container_registry_management_client.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import ContainerRegistryManagementClientConfiguration +from .operations import ( + Operations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """ContainerRegistryManagementClient. + + :ivar registries: RegistriesOperations operations + :vartype registries: azure.mgmt.containerregistry.v2022_12_01.operations.RegistriesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.containerregistry.v2022_12_01.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.containerregistry.v2022_12_01.operations.PrivateEndpointConnectionsOperations + :ivar replications: ReplicationsOperations operations + :vartype replications: + azure.mgmt.containerregistry.v2022_12_01.operations.ReplicationsOperations + :ivar scope_maps: ScopeMapsOperations operations + :vartype scope_maps: azure.mgmt.containerregistry.v2022_12_01.operations.ScopeMapsOperations + :ivar tokens: TokensOperations operations + :vartype tokens: azure.mgmt.containerregistry.v2022_12_01.operations.TokensOperations + :ivar webhooks: WebhooksOperations operations + :vartype webhooks: azure.mgmt.containerregistry.v2022_12_01.operations.WebhooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2022-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + 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 + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "ContainerRegistryManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_metadata.json new file mode 100644 index 000000000000..a06e16177fbe --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_metadata.json @@ -0,0 +1,108 @@ +{ + "chosen_version": "2022-12-01", + "total_api_version_list": ["2022-12-01"], + "client": { + "name": "ContainerRegistryManagementClient", + "filename": "_container_registry_management_client", + "description": "ContainerRegistryManagementClient.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "registries": "RegistriesOperations", + "operations": "Operations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "replications": "ReplicationsOperations", + "scope_maps": "ScopeMapsOperations", + "tokens": "TokensOperations", + "webhooks": "WebhooksOperations" + } +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.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) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + 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] + template = "/".join(components) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/__init__.py new file mode 100644 index 000000000000..2b9f561654c9 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._container_registry_management_client import ContainerRegistryManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_configuration.py new file mode 100644 index 000000000000..fcbd66e28356 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ContainerRegistryManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-containerregistry/{}".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") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_container_registry_management_client.py new file mode 100644 index 000000000000..0543ddad3735 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_container_registry_management_client.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import ContainerRegistryManagementClientConfiguration +from .operations import ( + Operations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """ContainerRegistryManagementClient. + + :ivar registries: RegistriesOperations operations + :vartype registries: + azure.mgmt.containerregistry.v2022_12_01.aio.operations.RegistriesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.containerregistry.v2022_12_01.aio.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.containerregistry.v2022_12_01.aio.operations.PrivateEndpointConnectionsOperations + :ivar replications: ReplicationsOperations operations + :vartype replications: + azure.mgmt.containerregistry.v2022_12_01.aio.operations.ReplicationsOperations + :ivar scope_maps: ScopeMapsOperations operations + :vartype scope_maps: + azure.mgmt.containerregistry.v2022_12_01.aio.operations.ScopeMapsOperations + :ivar tokens: TokensOperations operations + :vartype tokens: azure.mgmt.containerregistry.v2022_12_01.aio.operations.TokensOperations + :ivar webhooks: WebhooksOperations operations + :vartype webhooks: azure.mgmt.containerregistry.v2022_12_01.aio.operations.WebhooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2022-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + 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 + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ContainerRegistryManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/__init__.py new file mode 100644 index 000000000000..f775bbfd22aa --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._registries_operations import RegistriesOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._replications_operations import ReplicationsOperations +from ._scope_maps_operations import ScopeMapsOperations +from ._tokens_operations import TokensOperations +from ._webhooks_operations import WebhooksOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "RegistriesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_operations.py new file mode 100644 index 000000000000..1099ffe6f6f7 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_operations.py @@ -0,0 +1,137 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: + """Lists all of the available Azure Container Registry REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..95f9231b7a6b --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,600 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List all private endpoint connections in a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_12_01.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_12_01.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_registries_operations.py new file mode 100644 index 000000000000..14329234c398 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_registries_operations.py @@ -0,0 +1,1884 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_private_link_resource_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _import_image_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._import_image_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def check_name_availability( + self, + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: + """Lists all the container registries under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: + """Lists all the container registries under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: + """Gets the properties of the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _create_initial( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: _models.Registry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry=registry, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry_update_parameters=registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace_async + async def list_usages( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: + """Gets the quota usages for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryUsageListResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) + + request = build_list_usages_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } + + @distributed_trace + def list_private_link_resources( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Lists the private link resources for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_link_resources_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } + + @distributed_trace_async + async def get_private_link_resource( + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource by a specified group name for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param group_name: The name of the private link resource. Required. + :type group_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) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_private_link_resource_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } + + @distributed_trace_async + async def list_credentials( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Lists the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Is either a model type or a IO type. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") + + request = build_regenerate_credential_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } + + async def _generate_credentials_initial( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> Optional[_models.GenerateCredentialsResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters 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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._generate_credentials_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + generate_credentials_parameters=generate_credentials_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_replications_operations.py new file mode 100644 index 000000000000..b8a6e261a484 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_replications_operations.py @@ -0,0 +1,840 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: + """Lists all the replications for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Replication or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: + """Gets the properties of the specified replication. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Replication or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication=replication, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a replication from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication_update_parameters=replication_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_scope_maps_operations.py new file mode 100644 index 000000000000..9e2240eef354 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_scope_maps_operations.py @@ -0,0 +1,846 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: + """Lists all the scope maps for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeMap or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ScopeMapListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: + """Gets the properties of the specified scope map. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeMap or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap 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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_create_parameters=scope_map_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a scope map from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters 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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_update_parameters=scope_map_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_tokens_operations.py new file mode 100644 index 000000000000..bb284afed2ef --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_tokens_operations.py @@ -0,0 +1,837 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: + """Lists all the tokens for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Token or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TokenListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: + """Gets the properties of the specified token. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Token or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Token + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_create_parameters=token_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a token from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_update_parameters=token_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_webhooks_operations.py new file mode 100644 index 000000000000..3c1b7dee09d5 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_webhooks_operations.py @@ -0,0 +1,1071 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: + """Lists all the webhooks for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WebhookListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: + """Gets the properties of the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Webhook or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Webhook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters 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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_create_parameters=webhook_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a webhook from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters 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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_update_parameters=webhook_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace_async + async def ping( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: + """Triggers a ping event to be sent to the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventInfo or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.EventInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) + + request = build_ping_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } + + @distributed_trace + def list_events( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: + """Lists recent events for the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_events_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } + + @distributed_trace_async + async def get_callback_config( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: + """Gets the configuration of service URI and custom headers for the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallbackConfig or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.CallbackConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) + + request = build_get_callback_config_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CallbackConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/__init__.py new file mode 100644 index 000000000000..5af51fcc423f --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/__init__.py @@ -0,0 +1,219 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ActiveDirectoryObject +from ._models_py3 import Actor +from ._models_py3 import CallbackConfig +from ._models_py3 import EncryptionProperty +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import Event +from ._models_py3 import EventContent +from ._models_py3 import EventInfo +from ._models_py3 import EventListResult +from ._models_py3 import EventRequestMessage +from ._models_py3 import EventResponseMessage +from ._models_py3 import ExportPolicy +from ._models_py3 import GenerateCredentialsParameters +from ._models_py3 import GenerateCredentialsResult +from ._models_py3 import IPRule +from ._models_py3 import IdentityProperties +from ._models_py3 import ImportImageParameters +from ._models_py3 import ImportSource +from ._models_py3 import ImportSourceCredentials +from ._models_py3 import InnerErrorDescription +from ._models_py3 import KeyVaultProperties +from ._models_py3 import NetworkRuleSet +from ._models_py3 import OperationDefinition +from ._models_py3 import OperationDisplayDefinition +from ._models_py3 import OperationListResult +from ._models_py3 import OperationLogSpecificationDefinition +from ._models_py3 import OperationMetricSpecificationDefinition +from ._models_py3 import OperationServiceSpecificationDefinition +from ._models_py3 import PackageType +from ._models_py3 import Policies +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProxyResource +from ._models_py3 import QuarantinePolicy +from ._models_py3 import RegenerateCredentialParameters +from ._models_py3 import Registry +from ._models_py3 import RegistryListCredentialsResult +from ._models_py3 import RegistryListResult +from ._models_py3 import RegistryNameCheckRequest +from ._models_py3 import RegistryNameStatus +from ._models_py3 import RegistryPassword +from ._models_py3 import RegistryUpdateParameters +from ._models_py3 import RegistryUsage +from ._models_py3 import RegistryUsageListResult +from ._models_py3 import Replication +from ._models_py3 import ReplicationListResult +from ._models_py3 import ReplicationUpdateParameters +from ._models_py3 import Request +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import ScopeMap +from ._models_py3 import ScopeMapListResult +from ._models_py3 import ScopeMapUpdateParameters +from ._models_py3 import Sku +from ._models_py3 import Source +from ._models_py3 import Status +from ._models_py3 import StorageAccountProperties +from ._models_py3 import SystemData +from ._models_py3 import Target +from ._models_py3 import Token +from ._models_py3 import TokenCertificate +from ._models_py3 import TokenCredentialsProperties +from ._models_py3 import TokenListResult +from ._models_py3 import TokenPassword +from ._models_py3 import TokenUpdateParameters +from ._models_py3 import TrustPolicy +from ._models_py3 import UserIdentityProperties +from ._models_py3 import Webhook +from ._models_py3 import WebhookCreateParameters +from ._models_py3 import WebhookListResult +from ._models_py3 import WebhookUpdateParameters + +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ActiveDirectoryObject", + "Actor", + "CallbackConfig", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "PackageType", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "Source", + "Status", + "StorageAccountProperties", + "SystemData", + "Target", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ConnectionStatus", + "CreatedByType", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "NetworkRuleBypassOptions", + "PasswordName", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_container_registry_management_client_enums.py new file mode 100644 index 000000000000..d7d263b0717e --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_container_registry_management_client_enums.py @@ -0,0 +1,204 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of IP ACL rule.""" + + ALLOW = "Allow" + + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" + + NONE = "None" + RECREATE = "Recreate" + + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" + + APPROVED = "Approved" + PENDING = "Pending" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" + + ALLOW = "Allow" + DENY = "Deny" + + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When Force, any existing target tags will be overwritten. When NoForce, any existing target + tags will fail the operation before any copying begins. + """ + + NO_FORCE = "NoForce" + FORCE = "Force" + + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" + + AZURE_SERVICES = "AzureServices" + NONE = "None" + + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" + + PASSWORD = "password" + PASSWORD2 = "password2" + + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of private endpoint connection resource.""" + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" + + COUNT = "Count" + BYTES = "Bytes" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" + + CLASSIC = "Classic" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" + + CLASSIC = "Classic" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" + + CERTIFICATE1 = "certificate1" + CERTIFICATE2 = "certificate2" + + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" + + PASSWORD1 = "password1" + PASSWORD2 = "password2" + + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" + + NOTARY = "Notary" + + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" + + PUSH = "push" + DELETE = "delete" + QUARANTINE = "quarantine" + CHART_PUSH = "chart_push" + CHART_DELETE = "chart_delete" + + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_models_py3.py new file mode 100644 index 000000000000..33cceaea6036 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_models_py3.py @@ -0,0 +1,3461 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ActiveDirectoryObject(_serialization.Model): + """The Active Directory Object that will be used for authenticating the token of a container registry. + + :ivar object_id: The user/group/application object ID for Active Directory Object that will be + used for authenticating the token of a container registry. + :vartype object_id: str + :ivar tenant_id: The tenant ID of user/group/application object Active Directory Object that + will be used for authenticating the token of a container registry. + :vartype tenant_id: str + """ + + _attribute_map = { + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): + """ + :keyword object_id: The user/group/application object ID for Active Directory Object that will + be used for authenticating the token of a container registry. + :paramtype object_id: str + :keyword tenant_id: The tenant ID of user/group/application object Active Directory Object that + will be used for authenticating the token of a container registry. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) + self.object_id = object_id + self.tenant_id = tenant_id + + +class Actor(_serialization.Model): + """The agent that initiated the event. For most situations, this could be from the authorization context of the request. + + :ivar name: The subject or username associated with the request context that generated the + event. + :vartype name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The subject or username associated with the request context that generated the + event. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class CallbackConfig(_serialization.Model): + """The configuration of service URI and custom headers for the webhook. + + All required parameters must be populated in order to send to Azure. + + :ivar service_uri: The service URI for the webhook to post notifications. Required. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + """ + + _validation = { + "service_uri": {"required": True}, + } + + _attribute_map = { + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, + } + + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword service_uri: The service URI for the webhook to post notifications. Required. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + """ + super().__init__(**kwargs) + self.service_uri = service_uri + self.custom_headers = custom_headers + + +class EncryptionProperty(_serialization.Model): + """EncryptionProperty. + + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionStatus + :ivar key_vault_properties: Key vault properties. + :vartype key_vault_properties: + ~azure.mgmt.containerregistry.v2022_12_01.models.KeyVaultProperties + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + **kwargs + ): + """ + :keyword status: Indicates whether or not the encryption is enabled for container registry. + Known values are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionStatus + :keyword key_vault_properties: Key vault properties. + :paramtype key_vault_properties: + ~azure.mgmt.containerregistry.v2022_12_01.models.KeyVaultProperties + """ + super().__init__(**kwargs) + self.status = status + self.key_vault_properties = key_vault_properties + + +class ErrorResponse(_serialization.Model): + """An error response from the Azure Container Registry service. + + :ivar error: Azure container registry build API error body. + :vartype error: ~azure.mgmt.containerregistry.v2022_12_01.models.ErrorResponseBody + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseBody"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): + """ + :keyword error: Azure container registry build API error body. + :paramtype error: ~azure.mgmt.containerregistry.v2022_12_01.models.ErrorResponseBody + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseBody(_serialization.Model): + """An error response from the Azure Container Registry service. + + All required parameters must be populated in order to send to Azure. + + :ivar code: error code. Required. + :vartype code: str + :ivar message: error message. Required. + :vartype message: str + :ivar target: target of the particular error. + :vartype target: str + :ivar details: an array of additional nested error response info objects, as described by this + contract. + :vartype details: list[~azure.mgmt.containerregistry.v2022_12_01.models.InnerErrorDescription] + """ + + _validation = { + "code": {"required": True}, + "message": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, + } + + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, + **kwargs + ): + """ + :keyword code: error code. Required. + :paramtype code: str + :keyword message: error message. Required. + :paramtype message: str + :keyword target: target of the particular error. + :paramtype target: str + :keyword details: an array of additional nested error response info objects, as described by + this contract. + :paramtype details: + list[~azure.mgmt.containerregistry.v2022_12_01.models.InnerErrorDescription] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class EventInfo(_serialization.Model): + """The basic information of an event. + + :ivar id: The event ID. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The event ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class Event(EventInfo): + """The event for a webhook. + + :ivar id: The event ID. + :vartype id: str + :ivar event_request_message: The event request message sent to the service URI. + :vartype event_request_message: + ~azure.mgmt.containerregistry.v2022_12_01.models.EventRequestMessage + :ivar event_response_message: The event response message received from the service URI. + :vartype event_response_message: + ~azure.mgmt.containerregistry.v2022_12_01.models.EventResponseMessage + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, + **kwargs + ): + """ + :keyword id: The event ID. + :paramtype id: str + :keyword event_request_message: The event request message sent to the service URI. + :paramtype event_request_message: + ~azure.mgmt.containerregistry.v2022_12_01.models.EventRequestMessage + :keyword event_response_message: The event response message received from the service URI. + :paramtype event_response_message: + ~azure.mgmt.containerregistry.v2022_12_01.models.EventResponseMessage + """ + super().__init__(id=id, **kwargs) + self.event_request_message = event_request_message + self.event_response_message = event_response_message + + +class EventContent(_serialization.Model): + """The content of the event request message. + + :ivar id: The event ID. + :vartype id: str + :ivar timestamp: The time at which the event occurred. + :vartype timestamp: ~datetime.datetime + :ivar action: The action that encompasses the provided event. + :vartype action: str + :ivar target: The target of the event. + :vartype target: ~azure.mgmt.containerregistry.v2022_12_01.models.Target + :ivar request: The request that generated the event. + :vartype request: ~azure.mgmt.containerregistry.v2022_12_01.models.Request + :ivar actor: The agent that initiated the event. For most situations, this could be from the + authorization context of the request. + :vartype actor: ~azure.mgmt.containerregistry.v2022_12_01.models.Actor + :ivar source: The registry node that generated the event. Put differently, while the actor + initiates the event, the source generates it. + :vartype source: ~azure.mgmt.containerregistry.v2022_12_01.models.Source + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + timestamp: Optional[datetime.datetime] = None, + action: Optional[str] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, + **kwargs + ): + """ + :keyword id: The event ID. + :paramtype id: str + :keyword timestamp: The time at which the event occurred. + :paramtype timestamp: ~datetime.datetime + :keyword action: The action that encompasses the provided event. + :paramtype action: str + :keyword target: The target of the event. + :paramtype target: ~azure.mgmt.containerregistry.v2022_12_01.models.Target + :keyword request: The request that generated the event. + :paramtype request: ~azure.mgmt.containerregistry.v2022_12_01.models.Request + :keyword actor: The agent that initiated the event. For most situations, this could be from the + authorization context of the request. + :paramtype actor: ~azure.mgmt.containerregistry.v2022_12_01.models.Actor + :keyword source: The registry node that generated the event. Put differently, while the actor + initiates the event, the source generates it. + :paramtype source: ~azure.mgmt.containerregistry.v2022_12_01.models.Source + """ + super().__init__(**kwargs) + self.id = id + self.timestamp = timestamp + self.action = action + self.target = target + self.request = request + self.actor = actor + self.source = source + + +class EventListResult(_serialization.Model): + """The result of a request to list events for a webhook. + + :ivar value: The list of events. Since this list may be incomplete, the nextLink field should + be used to request the next list of events. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Event] + :ivar next_link: The URI that can be used to request the next list of events. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of events. Since this list may be incomplete, the nextLink field + should be used to request the next list of events. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Event] + :keyword next_link: The URI that can be used to request the next list of events. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class EventRequestMessage(_serialization.Model): + """The event request message sent to the service URI. + + :ivar content: The content of the event request message. + :vartype content: ~azure.mgmt.containerregistry.v2022_12_01.models.EventContent + :ivar headers: The headers of the event request message. + :vartype headers: dict[str, str] + :ivar method: The HTTP method used to send the event request message. + :vartype method: str + :ivar request_uri: The URI used to send the event request message. + :vartype request_uri: str + :ivar version: The HTTP message version. + :vartype version: str + """ + + _attribute_map = { + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + content: Optional["_models.EventContent"] = None, + headers: Optional[Dict[str, str]] = None, + method: Optional[str] = None, + request_uri: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword content: The content of the event request message. + :paramtype content: ~azure.mgmt.containerregistry.v2022_12_01.models.EventContent + :keyword headers: The headers of the event request message. + :paramtype headers: dict[str, str] + :keyword method: The HTTP method used to send the event request message. + :paramtype method: str + :keyword request_uri: The URI used to send the event request message. + :paramtype request_uri: str + :keyword version: The HTTP message version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.content = content + self.headers = headers + self.method = method + self.request_uri = request_uri + self.version = version + + +class EventResponseMessage(_serialization.Model): + """The event response message received from the service URI. + + :ivar content: The content of the event response message. + :vartype content: str + :ivar headers: The headers of the event response message. + :vartype headers: dict[str, str] + :ivar reason_phrase: The reason phrase of the event response message. + :vartype reason_phrase: str + :ivar status_code: The status code of the event response message. + :vartype status_code: str + :ivar version: The HTTP message version. + :vartype version: str + """ + + _attribute_map = { + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + content: Optional[str] = None, + headers: Optional[Dict[str, str]] = None, + reason_phrase: Optional[str] = None, + status_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword content: The content of the event response message. + :paramtype content: str + :keyword headers: The headers of the event response message. + :paramtype headers: dict[str, str] + :keyword reason_phrase: The reason phrase of the event response message. + :paramtype reason_phrase: str + :keyword status_code: The status code of the event response message. + :paramtype status_code: str + :keyword version: The HTTP message version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.content = content + self.headers = headers + self.reason_phrase = reason_phrase + self.status_code = status_code + self.version = version + + +class ExportPolicy(_serialization.Model): + """The export policy for a container registry. + + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ExportPolicyStatus + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): + """ + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ExportPolicyStatus + """ + super().__init__(**kwargs) + self.status = status + + +class GenerateCredentialsParameters(_serialization.Model): + """The parameters used to generate credentials for a specified token or user of a container registry. + + :ivar token_id: The resource ID of the token for which credentials have to be generated. + :vartype token_id: str + :ivar expiry: The expiry date of the generated credentials after which the credentials become + invalid. + :vartype expiry: ~datetime.datetime + :ivar name: Specifies name of the password which should be regenerated if any -- password1 or + password2. Known values are: "password1" and "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenPasswordName + """ + + _attribute_map = { + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__( + self, + *, + token_id: Optional[str] = None, + expiry: Optional[datetime.datetime] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, + **kwargs + ): + """ + :keyword token_id: The resource ID of the token for which credentials have to be generated. + :paramtype token_id: str + :keyword expiry: The expiry date of the generated credentials after which the credentials + become invalid. + :paramtype expiry: ~datetime.datetime + :keyword name: Specifies name of the password which should be regenerated if any -- password1 + or password2. Known values are: "password1" and "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenPasswordName + """ + super().__init__(**kwargs) + self.token_id = token_id + self.expiry = expiry + self.name = name + + +class GenerateCredentialsResult(_serialization.Model): + """The response from the GenerateCredentials operation. + + :ivar username: The username for a container registry. + :vartype username: str + :ivar passwords: The list of passwords for a container registry. + :vartype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenPassword] + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, + } + + def __init__( + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs + ): + """ + :keyword username: The username for a container registry. + :paramtype username: str + :keyword passwords: The list of passwords for a container registry. + :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenPassword] + """ + super().__init__(**kwargs) + self.username = username + self.passwords = passwords + + +class IdentityProperties(_serialization.Model): + """Managed identity for the resource. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity + dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.containerregistry.v2022_12_01.models.UserIdentityProperties] + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + tenant_id: Optional[str] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, + **kwargs + ): + """ + :keyword principal_id: The principal ID of resource identity. + :paramtype principal_id: str + :keyword tenant_id: The tenant ID of resource. + :paramtype tenant_id: str + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity + dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.containerregistry.v2022_12_01.models.UserIdentityProperties] + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.tenant_id = tenant_id + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ImportImageParameters(_serialization.Model): + """ImportImageParameters. + + All required parameters must be populated in order to send to Azure. + + :ivar source: The source of the image. Required. + :vartype source: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportSource + :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will + be used (or 'latest' if source tag is also omitted). + :vartype target_tags: list[str] + :ivar untagged_target_repositories: List of strings of repository names to do a manifest only + copy. No tag will be created. + :vartype untagged_target_repositories: list[str] + :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". + :vartype mode: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ImportMode + """ + + _validation = { + "source": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, + } + + def __init__( + self, + *, + source: "_models.ImportSource", + target_tags: Optional[List[str]] = None, + untagged_target_repositories: Optional[List[str]] = None, + mode: Union[str, "_models.ImportMode"] = "NoForce", + **kwargs + ): + """ + :keyword source: The source of the image. Required. + :paramtype source: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportSource + :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source + will be used (or 'latest' if source tag is also omitted). + :paramtype target_tags: list[str] + :keyword untagged_target_repositories: List of strings of repository names to do a manifest + only copy. No tag will be created. + :paramtype untagged_target_repositories: list[str] + :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". + :paramtype mode: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ImportMode + """ + super().__init__(**kwargs) + self.source = source + self.target_tags = target_tags + self.untagged_target_repositories = untagged_target_repositories + self.mode = mode + + +class ImportSource(_serialization.Model): + """ImportSource. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_id: The resource identifier of the source Azure Container Registry. + :vartype resource_id: str + :ivar registry_uri: The address of the source registry (e.g. 'mcr.microsoft.com'). + :vartype registry_uri: str + :ivar credentials: Credentials used when importing from a registry uri. + :vartype credentials: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportSourceCredentials + :ivar source_image: Repository name of the source image. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. + :vartype source_image: str + """ + + _validation = { + "source_image": {"required": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, + } + + def __init__( + self, + *, + source_image: str, + resource_id: Optional[str] = None, + registry_uri: Optional[str] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, + **kwargs + ): + """ + :keyword resource_id: The resource identifier of the source Azure Container Registry. + :paramtype resource_id: str + :keyword registry_uri: The address of the source registry (e.g. 'mcr.microsoft.com'). + :paramtype registry_uri: str + :keyword credentials: Credentials used when importing from a registry uri. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2022_12_01.models.ImportSourceCredentials + :keyword source_image: Repository name of the source image. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. + :paramtype source_image: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.registry_uri = registry_uri + self.credentials = credentials + self.source_image = source_image + + +class ImportSourceCredentials(_serialization.Model): + """ImportSourceCredentials. + + All required parameters must be populated in order to send to Azure. + + :ivar username: The username to authenticate with the source registry. + :vartype username: str + :ivar password: The password used to authenticate with the source registry. Required. + :vartype password: str + """ + + _validation = { + "password": {"required": True}, + } + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): + """ + :keyword username: The username to authenticate with the source registry. + :paramtype username: str + :keyword password: The password used to authenticate with the source registry. Required. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class InnerErrorDescription(_serialization.Model): + """inner error. + + All required parameters must be populated in order to send to Azure. + + :ivar code: error code. Required. + :vartype code: str + :ivar message: error message. Required. + :vartype message: str + :ivar target: target of the particular error. + :vartype target: str + """ + + _validation = { + "code": {"required": True}, + "message": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): + """ + :keyword code: error code. Required. + :paramtype code: str + :keyword message: error message. Required. + :paramtype message: str + :keyword target: target of the particular error. + :paramtype target: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + + +class IPRule(_serialization.Model): + """IP rule with specific IP or IP range in CIDR format. + + All required parameters must be populated in order to send to Azure. + + :ivar action: The action of IP ACL rule. "Allow" + :vartype action: str or ~azure.mgmt.containerregistry.v2022_12_01.models.Action + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :vartype ip_address_or_range: str + """ + + _validation = { + "ip_address_or_range": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, + } + + def __init__(self, *, ip_address_or_range: str, action: Union[str, "_models.Action"] = "Allow", **kwargs): + """ + :keyword action: The action of IP ACL rule. "Allow" + :paramtype action: str or ~azure.mgmt.containerregistry.v2022_12_01.models.Action + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :paramtype ip_address_or_range: str + """ + super().__init__(**kwargs) + self.action = action + self.ip_address_or_range = ip_address_or_range + + +class KeyVaultProperties(_serialization.Model): + """KeyVaultProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_identifier: Key vault uri to access the encryption key. + :vartype key_identifier: str + :ivar versioned_key_identifier: The fully qualified key identifier that includes the version of + the key that is actually used for encryption. + :vartype versioned_key_identifier: str + :ivar identity: The client id of the identity which will be used to access key vault. + :vartype identity: str + :ivar key_rotation_enabled: Auto key rotation status for a CMK enabled registry. + :vartype key_rotation_enabled: bool + :ivar last_key_rotation_timestamp: Timestamp of the last successful key rotation. + :vartype last_key_rotation_timestamp: ~datetime.datetime + """ + + _validation = { + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + } + + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): + """ + :keyword key_identifier: Key vault uri to access the encryption key. + :paramtype key_identifier: str + :keyword identity: The client id of the identity which will be used to access key vault. + :paramtype identity: str + """ + super().__init__(**kwargs) + self.key_identifier = key_identifier + self.versioned_key_identifier = None + self.identity = identity + self.key_rotation_enabled = None + self.last_key_rotation_timestamp = None + + +class NetworkRuleSet(_serialization.Model): + """The network rule set for a container registry. + + All required parameters must be populated in order to send to Azure. + + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.containerregistry.v2022_12_01.models.DefaultAction + :ivar ip_rules: The IP ACL rules. + :vartype ip_rules: list[~azure.mgmt.containerregistry.v2022_12_01.models.IPRule] + """ + + _validation = { + "default_action": {"required": True}, + } + + _attribute_map = { + "default_action": {"key": "defaultAction", "type": "str"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + } + + def __init__( + self, + *, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + ip_rules: Optional[List["_models.IPRule"]] = None, + **kwargs + ): + """ + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". + :paramtype default_action: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.DefaultAction + :keyword ip_rules: The IP ACL rules. + :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2022_12_01.models.IPRule] + """ + super().__init__(**kwargs) + self.default_action = default_action + self.ip_rules = ip_rules + + +class OperationDefinition(_serialization.Model): + """The definition of a container registry operation. + + :ivar origin: The origin information of the container registry operation. + :vartype origin: str + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The display information for the container registry operation. + :vartype display: ~azure.mgmt.containerregistry.v2022_12_01.models.OperationDisplayDefinition + :ivar is_data_action: This property indicates if the operation is an action or a data action + ref: + https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations. + :vartype is_data_action: bool + :ivar service_specification: The definition of Azure Monitoring service. + :vartype service_specification: + ~azure.mgmt.containerregistry.v2022_12_01.models.OperationServiceSpecificationDefinition + """ + + _attribute_map = { + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, + } + + def __init__( + self, + *, + origin: Optional[str] = None, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + is_data_action: Optional[bool] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, + **kwargs + ): + """ + :keyword origin: The origin information of the container registry operation. + :paramtype origin: str + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The display information for the container registry operation. + :paramtype display: ~azure.mgmt.containerregistry.v2022_12_01.models.OperationDisplayDefinition + :keyword is_data_action: This property indicates if the operation is an action or a data action + ref: + https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations. + :paramtype is_data_action: bool + :keyword service_specification: The definition of Azure Monitoring service. + :paramtype service_specification: + ~azure.mgmt.containerregistry.v2022_12_01.models.OperationServiceSpecificationDefinition + """ + super().__init__(**kwargs) + self.origin = origin + self.name = name + self.display = display + self.is_data_action = is_data_action + self.service_specification = service_specification + + +class OperationDisplayDefinition(_serialization.Model): + """The display information for a container registry operation. + + :ivar provider: The resource provider name: Microsoft.ContainerRegistry. + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation that users can perform. + :vartype operation: str + :ivar description: The description for the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: The resource provider name: Microsoft.ContainerRegistry. + :paramtype provider: str + :keyword resource: The resource on which the operation is performed. + :paramtype resource: str + :keyword operation: The operation that users can perform. + :paramtype operation: str + :keyword description: The description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """The result of a request to list container registry operations. + + :ivar value: The list of container registry operations. Since this list may be incomplete, the + nextLink field should be used to request the next list of operations. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationDefinition] + :ivar next_link: The URI that can be used to request the next list of container registry + operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of container registry operations. Since this list may be incomplete, + the nextLink field should be used to request the next list of operations. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationDefinition] + :keyword next_link: The URI that can be used to request the next list of container registry + operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationLogSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring log. + + :ivar name: Log name. + :vartype name: str + :ivar display_name: Log display name. + :vartype display_name: str + :ivar blob_duration: Log blob duration. + :vartype blob_duration: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Log name. + :paramtype name: str + :keyword display_name: Log display name. + :paramtype display_name: str + :keyword blob_duration: Log blob duration. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.blob_duration = blob_duration + + +class OperationMetricSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring metric. + + :ivar name: Metric name. + :vartype name: str + :ivar display_name: Metric display name. + :vartype display_name: str + :ivar display_description: Metric description. + :vartype display_description: str + :ivar unit: Metric unit. + :vartype unit: str + :ivar aggregation_type: Metric aggregation type. + :vartype aggregation_type: str + :ivar internal_metric_name: Internal metric name. + :vartype internal_metric_name: str + """ + + _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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + internal_metric_name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Metric name. + :paramtype name: str + :keyword display_name: Metric display name. + :paramtype display_name: str + :keyword display_description: Metric description. + :paramtype display_description: str + :keyword unit: Metric unit. + :paramtype unit: str + :keyword aggregation_type: Metric aggregation type. + :paramtype aggregation_type: str + :keyword internal_metric_name: Internal metric name. + :paramtype internal_metric_name: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.aggregation_type = aggregation_type + self.internal_metric_name = internal_metric_name + + +class OperationServiceSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring list. + + :ivar metric_specifications: A list of Azure Monitoring metrics definition. + :vartype metric_specifications: + list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationMetricSpecificationDefinition] + :ivar log_specifications: A list of Azure Monitoring log definitions. + :vartype log_specifications: + list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationLogSpecificationDefinition] + """ + + _attribute_map = { + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, + } + + def __init__( + self, + *, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, + **kwargs + ): + """ + :keyword metric_specifications: A list of Azure Monitoring metrics definition. + :paramtype metric_specifications: + list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationMetricSpecificationDefinition] + :keyword log_specifications: A list of Azure Monitoring log definitions. + :paramtype log_specifications: + list[~azure.mgmt.containerregistry.v2022_12_01.models.OperationLogSpecificationDefinition] + """ + super().__init__(**kwargs) + self.metric_specifications = metric_specifications + self.log_specifications = log_specifications + + +class PackageType(_serialization.Model): + """The properties of a package type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the package type. + :vartype name: str + :ivar endpoint: The endpoint of the package type. + :vartype endpoint: str + """ + + _validation = { + "endpoint": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The name of the package type. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.endpoint = None + + +class Policies(_serialization.Model): + """The policies for a container registry. + + :ivar quarantine_policy: The quarantine policy for a container registry. + :vartype quarantine_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.QuarantinePolicy + :ivar trust_policy: The content trust policy for a container registry. + :vartype trust_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.TrustPolicy + :ivar retention_policy: The retention policy for a container registry. + :vartype retention_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.RetentionPolicy + :ivar export_policy: The export policy for a container registry. + :vartype export_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.ExportPolicy + """ + + _attribute_map = { + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, + } + + def __init__( + self, + *, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, + **kwargs + ): + """ + :keyword quarantine_policy: The quarantine policy for a container registry. + :paramtype quarantine_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.QuarantinePolicy + :keyword trust_policy: The content trust policy for a container registry. + :paramtype trust_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.TrustPolicy + :keyword retention_policy: The retention policy for a container registry. + :paramtype retention_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.RetentionPolicy + :keyword export_policy: The export policy for a container registry. + :paramtype export_policy: ~azure.mgmt.containerregistry.v2022_12_01.models.ExportPolicy + """ + super().__init__(**kwargs) + self.quarantine_policy = quarantine_policy + self.trust_policy = trust_policy + self.retention_policy = retention_policy + self.export_policy = export_policy + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: This is private endpoint resource created with Microsoft.Network resource + provider. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class ProxyResource(_serialization.Model): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + """ + + _validation = { + "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"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class PrivateEndpointConnection(ProxyResource): + """An object that represents a private endpoint connection for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar private_endpoint: The resource of private endpoint. + :vartype private_endpoint: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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"}, + "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__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The resource of private endpoint. + :paramtype private_endpoint: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkServiceConnectionState + """ + 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(_serialization.Model): + """The result of a request to list private endpoint connections for a container registry. + + :ivar value: The list of private endpoint connections. Since this list may be incomplete, the + nextLink field should be used to request the next list of private endpoint connections. + :vartype value: + list[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :ivar next_link: The URI that can be used to request the next list of private endpoint + connections. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of private endpoint connections. Since this list may be incomplete, + the nextLink field should be used to request the next list of private endpoint connections. + :paramtype value: + list[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :keyword next_link: The URI that can be used to request the next list of private endpoint + connections. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(_serialization.Model): + """A resource that supports private link capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The resource type is private link resource. + :vartype type: str + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "type": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword id: The resource ID. + :paramtype id: str + :keyword name: The name of the resource. + :paramtype name: str + :keyword group_id: The private link resource group id. + :paramtype group_id: str + :keyword required_members: The private link resource required member names. + :paramtype required_members: list[str] + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.type = None + self.id = id + self.name = name + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """The result of a request to list private link resources for a container registry. + + :ivar value: The list of private link resources. Since this list may be incomplete, the + nextLink field should be used to request the next list of private link resources. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource] + :ivar next_link: The URI that can be used to request the next list of private link resources. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of private link resources. Since this list may be incomplete, the + nextLink field should be used to request the next list of private link resources. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource] + :keyword next_link: The URI that can be used to request the next list of private link + resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The state of a private link service connection. + + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ConnectionStatus + :ivar description: The description for connection status. For example if connection is rejected + it can indicate reason for rejection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. Known values are: "None" and "Recreate". + :vartype actions_required: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ActionsRequired + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, + **kwargs + ): + """ + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.ConnectionStatus + :keyword description: The description for connection status. For example if connection is + rejected it can indicate reason for rejection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. Known values are: "None" and "Recreate". + :paramtype actions_required: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ActionsRequired + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class QuarantinePolicy(_serialization.Model): + """The quarantine policy for a container registry. + + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): + """ + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + super().__init__(**kwargs) + self.status = status + + +class RegenerateCredentialParameters(_serialization.Model): + """The parameters used to regenerate the login credential. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PasswordName + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): + """ + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PasswordName + """ + super().__init__(**kwargs) + self.name = name + + +class Resource(_serialization.Model): + """An Azure resource. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class Registry(Resource): # pylint: disable=too-many-instance-attributes + """An object that represents a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar sku: The SKU of the container registry. Required. + :vartype sku: ~azure.mgmt.containerregistry.v2022_12_01.models.Sku + :ivar identity: The identity of the container registry. + :vartype identity: ~azure.mgmt.containerregistry.v2022_12_01.models.IdentityProperties + :ivar login_server: The URL that can be used to log into the container registry. + :vartype login_server: str + :ivar creation_date: The creation date of the container registry in ISO8601 format. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the container registry at the time the + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + :ivar status: The status of the container registry at the time the operation was called. + :vartype status: ~azure.mgmt.containerregistry.v2022_12_01.models.Status + :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. + :vartype admin_user_enabled: bool + :ivar network_rule_set: The network rule set for a container registry. + :vartype network_rule_set: ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleSet + :ivar policies: The policies for a container registry. + :vartype policies: ~azure.mgmt.containerregistry.v2022_12_01.models.Policies + :ivar encryption: The encryption settings of container registry. + :vartype encryption: ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionProperty + :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :vartype data_endpoint_enabled: bool + :ivar data_endpoint_host_names: List of host names that will serve data when + dataEndpointEnabled is true. + :vartype data_endpoint_host_names: list[str] + :ivar private_endpoint_connections: List of private endpoint connections for a container + registry. + :vartype private_endpoint_connections: + list[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :ivar public_network_access: Whether or not public network access is allowed for the container + registry. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.PublicNetworkAccess + :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network + restricted registry. Known values are: "AzureServices" and "None". + :vartype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleBypassOptions + :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. + Known values are: "Enabled" and "Disabled". + :vartype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ZoneRedundancy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, + data_endpoint_enabled: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword sku: The SKU of the container registry. Required. + :paramtype sku: ~azure.mgmt.containerregistry.v2022_12_01.models.Sku + :keyword identity: The identity of the container registry. + :paramtype identity: ~azure.mgmt.containerregistry.v2022_12_01.models.IdentityProperties + :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. + :paramtype admin_user_enabled: bool + :keyword network_rule_set: The network rule set for a container registry. + :paramtype network_rule_set: ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleSet + :keyword policies: The policies for a container registry. + :paramtype policies: ~azure.mgmt.containerregistry.v2022_12_01.models.Policies + :keyword encryption: The encryption settings of container registry. + :paramtype encryption: ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionProperty + :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :paramtype data_endpoint_enabled: bool + :keyword public_network_access: Whether or not public network access is allowed for the + container registry. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.PublicNetworkAccess + :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a + network restricted registry. Known values are: "AzureServices" and "None". + :paramtype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleBypassOptions + :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container + registry. Known values are: "Enabled" and "Disabled". + :paramtype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ZoneRedundancy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.sku = sku + self.identity = identity + self.login_server = None + self.creation_date = None + self.provisioning_state = None + self.status = None + self.admin_user_enabled = admin_user_enabled + self.network_rule_set = network_rule_set + self.policies = policies + self.encryption = encryption + self.data_endpoint_enabled = data_endpoint_enabled + self.data_endpoint_host_names = None + self.private_endpoint_connections = None + self.public_network_access = public_network_access + self.network_rule_bypass_options = network_rule_bypass_options + self.zone_redundancy = zone_redundancy + + +class RegistryListCredentialsResult(_serialization.Model): + """The response from the ListCredentials operation. + + :ivar username: The username for a container registry. + :vartype username: str + :ivar passwords: The list of passwords for a container registry. + :vartype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.RegistryPassword] + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, + } + + def __init__( + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs + ): + """ + :keyword username: The username for a container registry. + :paramtype username: str + :keyword passwords: The list of passwords for a container registry. + :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.RegistryPassword] + """ + super().__init__(**kwargs) + self.username = username + self.passwords = passwords + + +class RegistryListResult(_serialization.Model): + """The result of a request to list container registries. + + :ivar value: The list of container registries. Since this list may be incomplete, the nextLink + field should be used to request the next list of container registries. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :ivar next_link: The URI that can be used to request the next list of container registries. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of container registries. Since this list may be incomplete, the + nextLink field should be used to request the next list of container registries. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :keyword next_link: The URI that can be used to request the next list of container registries. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RegistryNameCheckRequest(_serialization.Model): + """A request to check whether a container registry name is available. + + 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 name: The name of the container registry. Required. + :vartype name: str + :ivar type: The resource type of the container registry. This field must be set to + 'Microsoft.ContainerRegistry/registries'. Required. Default value is + "Microsoft.ContainerRegistry/registries". + :vartype type: str + """ + + _validation = { + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + type = "Microsoft.ContainerRegistry/registries" + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The name of the container registry. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class RegistryNameStatus(_serialization.Model): + """The result of a request to check the availability of a container registry name. + + :ivar name_available: The value that indicates whether the name is available. + :vartype name_available: bool + :ivar reason: If any, the reason that the name is not available. + :vartype reason: str + :ivar message: If any, the error message that provides more detail for the reason that the name + is not available. + :vartype message: str + """ + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: The value that indicates whether the name is available. + :paramtype name_available: bool + :keyword reason: If any, the reason that the name is not available. + :paramtype reason: str + :keyword message: If any, the error message that provides more detail for the reason that the + name is not available. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class RegistryPassword(_serialization.Model): + """The login password for the container registry. + + :ivar name: The password name. Known values are: "password" and "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PasswordName + :ivar value: The password value. + :vartype value: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs + ): + """ + :keyword name: The password name. Known values are: "password" and "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PasswordName + :keyword value: The password value. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class RegistryUpdateParameters(_serialization.Model): + """The parameters for updating a container registry. + + :ivar identity: The identity of the container registry. + :vartype identity: ~azure.mgmt.containerregistry.v2022_12_01.models.IdentityProperties + :ivar tags: The tags for the container registry. + :vartype tags: dict[str, str] + :ivar sku: The SKU of the container registry. + :vartype sku: ~azure.mgmt.containerregistry.v2022_12_01.models.Sku + :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. + :vartype admin_user_enabled: bool + :ivar network_rule_set: The network rule set for a container registry. + :vartype network_rule_set: ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleSet + :ivar policies: The policies for a container registry. + :vartype policies: ~azure.mgmt.containerregistry.v2022_12_01.models.Policies + :ivar encryption: The encryption settings of container registry. + :vartype encryption: ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionProperty + :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :vartype data_endpoint_enabled: bool + :ivar public_network_access: Whether or not public network access is allowed for the container + registry. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.PublicNetworkAccess + :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network + restricted registry. Known values are: "AzureServices" and "None". + :vartype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleBypassOptions + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + } + + def __init__( + self, + *, + identity: Optional["_models.IdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.Sku"] = None, + admin_user_enabled: Optional[bool] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, + data_endpoint_enabled: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + **kwargs + ): + """ + :keyword identity: The identity of the container registry. + :paramtype identity: ~azure.mgmt.containerregistry.v2022_12_01.models.IdentityProperties + :keyword tags: The tags for the container registry. + :paramtype tags: dict[str, str] + :keyword sku: The SKU of the container registry. + :paramtype sku: ~azure.mgmt.containerregistry.v2022_12_01.models.Sku + :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. + :paramtype admin_user_enabled: bool + :keyword network_rule_set: The network rule set for a container registry. + :paramtype network_rule_set: ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleSet + :keyword policies: The policies for a container registry. + :paramtype policies: ~azure.mgmt.containerregistry.v2022_12_01.models.Policies + :keyword encryption: The encryption settings of container registry. + :paramtype encryption: ~azure.mgmt.containerregistry.v2022_12_01.models.EncryptionProperty + :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :paramtype data_endpoint_enabled: bool + :keyword public_network_access: Whether or not public network access is allowed for the + container registry. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.PublicNetworkAccess + :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a + network restricted registry. Known values are: "AzureServices" and "None". + :paramtype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.NetworkRuleBypassOptions + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + self.sku = sku + self.admin_user_enabled = admin_user_enabled + self.network_rule_set = network_rule_set + self.policies = policies + self.encryption = encryption + self.data_endpoint_enabled = data_endpoint_enabled + self.public_network_access = public_network_access + self.network_rule_bypass_options = network_rule_bypass_options + + +class RegistryUsage(_serialization.Model): + """The quota usage for a container registry. + + :ivar name: The name of the usage. + :vartype name: str + :ivar limit: The limit of the usage. + :vartype limit: int + :ivar current_value: The current value of the usage. + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". + :vartype unit: str or ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageUnit + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + limit: Optional[int] = None, + current_value: Optional[int] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, + **kwargs + ): + """ + :keyword name: The name of the usage. + :paramtype name: str + :keyword limit: The limit of the usage. + :paramtype limit: int + :keyword current_value: The current value of the usage. + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". + :paramtype unit: str or ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageUnit + """ + super().__init__(**kwargs) + self.name = name + self.limit = limit + self.current_value = current_value + self.unit = unit + + +class RegistryUsageListResult(_serialization.Model): + """The result of a request to get container registry quota usages. + + :ivar value: The list of container registry quota usages. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsage] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RegistryUsage]"}, + } + + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): + """ + :keyword value: The list of container registry quota usages. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsage] + """ + super().__init__(**kwargs) + self.value = value + + +class Replication(Resource): + """An object that represents a replication for a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar provisioning_state: The provisioning state of the replication at the time the operation + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + :ivar status: The status of the replication at the time the operation was called. + :vartype status: ~azure.mgmt.containerregistry.v2022_12_01.models.Status + :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :vartype region_endpoint_enabled: bool + :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry + replication. Known values are: "Enabled" and "Disabled". + :vartype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ZoneRedundancy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :paramtype region_endpoint_enabled: bool + :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry + replication. Known values are: "Enabled" and "Disabled". + :paramtype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ZoneRedundancy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.provisioning_state = None + self.status = None + self.region_endpoint_enabled = region_endpoint_enabled + self.zone_redundancy = zone_redundancy + + +class ReplicationListResult(_serialization.Model): + """The result of a request to list replications for a container registry. + + :ivar value: The list of replications. Since this list may be incomplete, the nextLink field + should be used to request the next list of replications. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :ivar next_link: The URI that can be used to request the next list of replications. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of replications. Since this list may be incomplete, the nextLink field + should be used to request the next list of replications. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :keyword next_link: The URI that can be used to request the next list of replications. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ReplicationUpdateParameters(_serialization.Model): + """The parameters for updating a replication. + + :ivar tags: The tags for the replication. + :vartype tags: dict[str, str] + :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :vartype region_endpoint_enabled: bool + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + } + + def __init__( + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs + ): + """ + :keyword tags: The tags for the replication. + :paramtype tags: dict[str, str] + :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :paramtype region_endpoint_enabled: bool + """ + super().__init__(**kwargs) + self.tags = tags + self.region_endpoint_enabled = region_endpoint_enabled + + +class Request(_serialization.Model): + """The request that generated the event. + + :ivar id: The ID of the request that initiated the event. + :vartype id: str + :ivar addr: The IP or hostname and possibly port of the client connection that initiated the + event. This is the RemoteAddr from the standard http request. + :vartype addr: str + :ivar host: The externally accessible hostname of the registry instance, as specified by the + http host header on incoming requests. + :vartype host: str + :ivar method: The request method that generated the event. + :vartype method: str + :ivar useragent: The user agent header of the request. + :vartype useragent: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + addr: Optional[str] = None, + host: Optional[str] = None, + method: Optional[str] = None, + useragent: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The ID of the request that initiated the event. + :paramtype id: str + :keyword addr: The IP or hostname and possibly port of the client connection that initiated the + event. This is the RemoteAddr from the standard http request. + :paramtype addr: str + :keyword host: The externally accessible hostname of the registry instance, as specified by the + http host header on incoming requests. + :paramtype host: str + :keyword method: The request method that generated the event. + :paramtype method: str + :keyword useragent: The user agent header of the request. + :paramtype useragent: str + """ + super().__init__(**kwargs) + self.id = id + self.addr = addr + self.host = host + self.method = method + self.useragent = useragent + + +class RetentionPolicy(_serialization.Model): + """The retention policy for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar days: The number of days to retain an untagged manifest after which it gets purged. + :vartype days: int + :ivar last_updated_time: The timestamp when the policy was last updated. + :vartype last_updated_time: ~datetime.datetime + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + + _validation = { + "last_updated_time": {"readonly": True}, + } + + _attribute_map = { + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): + """ + :keyword days: The number of days to retain an untagged manifest after which it gets purged. + :paramtype days: int + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + super().__init__(**kwargs) + self.days = days + self.last_updated_time = None + self.status = status + + +class ScopeMap(ProxyResource): + """An object that represents a scope map for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar description: The user friendly description of the scope map. + :vartype description: str + :ivar type_properties_type: The type of the scope map. E.g. BuildIn scope map. + :vartype type_properties_type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + :ivar actions: The list of scoped permissions for registry artifacts. + E.g. repositories/repository-name/content/read, + repositories/repository-name/metadata/write. + :vartype actions: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): + """ + :keyword description: The user friendly description of the scope map. + :paramtype description: str + :keyword actions: The list of scoped permissions for registry artifacts. + E.g. repositories/repository-name/content/read, + repositories/repository-name/metadata/write. + :paramtype actions: list[str] + """ + super().__init__(**kwargs) + self.description = description + self.type_properties_type = None + self.creation_date = None + self.provisioning_state = None + self.actions = actions + + +class ScopeMapListResult(_serialization.Model): + """The result of a request to list scope maps for a container registry. + + :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field + should be used to request the next list of scope maps. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :ivar next_link: The URI that can be used to request the next list of scope maps. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field + should be used to request the next list of scope maps. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :keyword next_link: The URI that can be used to request the next list of scope maps. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ScopeMapUpdateParameters(_serialization.Model): + """The properties for updating the scope map. + + :ivar description: The user friendly description of the scope map. + :vartype description: str + :ivar actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete. + :vartype actions: list[str] + """ + + _attribute_map = { + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): + """ + :keyword description: The user friendly description of the scope map. + :paramtype description: str + :keyword actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete. + :paramtype actions: list[str] + """ + super().__init__(**kwargs) + self.description = description + self.actions = actions + + +class Sku(_serialization.Model): + """The SKU of a container registry. + + 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 name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.SkuName + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.containerregistry.v2022_12_01.models.SkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): + """ + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class Source(_serialization.Model): + """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + + :ivar addr: The IP or hostname and the port of the registry node that generated the event. + Generally, this will be resolved by os.Hostname() along with the running port. + :vartype addr: str + :ivar instance_id: The running instance of an application. Changes after each restart. + :vartype instance_id: str + """ + + _attribute_map = { + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, + } + + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): + """ + :keyword addr: The IP or hostname and the port of the registry node that generated the event. + Generally, this will be resolved by os.Hostname() along with the running port. + :paramtype addr: str + :keyword instance_id: The running instance of an application. Changes after each restart. + :paramtype instance_id: str + """ + super().__init__(**kwargs) + self.addr = addr + self.instance_id = instance_id + + +class Status(_serialization.Model): + """The status of an Azure resource at the time the operation was called. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_status: The short label for the status. + :vartype display_status: str + :ivar message: The detailed message for the status, including alerts and error messages. + :vartype message: str + :ivar timestamp: The timestamp when the status was changed to the current value. + :vartype timestamp: ~datetime.datetime + """ + + _validation = { + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, + } + + _attribute_map = { + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.display_status = None + self.message = None + self.timestamp = None + + +class StorageAccountProperties(_serialization.Model): + """The properties of a storage account for a container registry. Only applicable to Classic SKU. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID of the storage account. Required. + :vartype id: str + """ + + _validation = { + "id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The resource ID of the storage account. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +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", and "Key". + :vartype created_by_type: str or ~azure.mgmt.containerregistry.v2022_12_01.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", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.LastModifiedByType + :ivar last_modified_at: The timestamp of resource 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"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :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", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.containerregistry.v2022_12_01.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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.LastModifiedByType + :keyword last_modified_at: The timestamp of resource modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Target(_serialization.Model): + """The target of the event. + + :ivar media_type: The MIME type of the referenced object. + :vartype media_type: str + :ivar size: The number of bytes of the content. Same as Length field. + :vartype size: int + :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. + :vartype digest: str + :ivar length: The number of bytes of the content. Same as Size field. + :vartype length: int + :ivar repository: The repository name. + :vartype repository: str + :ivar url: The direct URL to the content. + :vartype url: str + :ivar tag: The tag name. + :vartype tag: str + :ivar name: The name of the artifact. + :vartype name: str + :ivar version: The version of the artifact. + :vartype version: str + """ + + _attribute_map = { + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + media_type: Optional[str] = None, + size: Optional[int] = None, + digest: Optional[str] = None, + length: Optional[int] = None, + repository: Optional[str] = None, + url: Optional[str] = None, + tag: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword media_type: The MIME type of the referenced object. + :paramtype media_type: str + :keyword size: The number of bytes of the content. Same as Length field. + :paramtype size: int + :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API + Specification. + :paramtype digest: str + :keyword length: The number of bytes of the content. Same as Size field. + :paramtype length: int + :keyword repository: The repository name. + :paramtype repository: str + :keyword url: The direct URL to the content. + :paramtype url: str + :keyword tag: The tag name. + :paramtype tag: str + :keyword name: The name of the artifact. + :paramtype name: str + :keyword version: The version of the artifact. + :paramtype version: str + """ + super().__init__(**kwargs) + self.media_type = media_type + self.size = size + self.digest = digest + self.length = length + self.repository = repository + self.url = url + self.tag = tag + self.name = name + self.version = version + + +class Token(ProxyResource): + """An object that represents a token for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar creation_date: The creation date of scope map. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + :ivar scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :vartype scope_map_id: str + :ivar credentials: The credentials that can be used for authenticating the token. + :vartype credentials: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCredentialsProperties + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, + } + + def __init__( + self, + *, + scope_map_id: Optional[str] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + **kwargs + ): + """ + :keyword scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :paramtype scope_map_id: str + :keyword credentials: The credentials that can be used for authenticating the token. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCredentialsProperties + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenStatus + """ + super().__init__(**kwargs) + self.creation_date = None + self.provisioning_state = None + self.scope_map_id = scope_map_id + self.credentials = credentials + self.status = status + + +class TokenCertificate(_serialization.Model): + """The properties of a certificate used for authenticating a token. + + :ivar name: Known values are: "certificate1" and "certificate2". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCertificateName + :ivar expiry: The expiry datetime of the certificate. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The thumbprint of the certificate. + :vartype thumbprint: str + :ivar encoded_pem_certificate: Base 64 encoded string of the public certificate1 in PEM format + that will be used for authenticating the token. + :vartype encoded_pem_certificate: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, + expiry: Optional[datetime.datetime] = None, + thumbprint: Optional[str] = None, + encoded_pem_certificate: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Known values are: "certificate1" and "certificate2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCertificateName + :keyword expiry: The expiry datetime of the certificate. + :paramtype expiry: ~datetime.datetime + :keyword thumbprint: The thumbprint of the certificate. + :paramtype thumbprint: str + :keyword encoded_pem_certificate: Base 64 encoded string of the public certificate1 in PEM + format that will be used for authenticating the token. + :paramtype encoded_pem_certificate: str + """ + super().__init__(**kwargs) + self.name = name + self.expiry = expiry + self.thumbprint = thumbprint + self.encoded_pem_certificate = encoded_pem_certificate + + +class TokenCredentialsProperties(_serialization.Model): + """The properties of the credentials that can be used for authenticating the token. + + :ivar certificates: + :vartype certificates: list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenCertificate] + :ivar passwords: + :vartype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenPassword] + """ + + _attribute_map = { + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, + } + + def __init__( + self, + *, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, + **kwargs + ): + """ + :keyword certificates: + :paramtype certificates: + list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenCertificate] + :keyword passwords: + :paramtype passwords: list[~azure.mgmt.containerregistry.v2022_12_01.models.TokenPassword] + """ + super().__init__(**kwargs) + self.certificates = certificates + self.passwords = passwords + + +class TokenListResult(_serialization.Model): + """The result of a request to list tokens for a container registry. + + :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should + be used to request the next list of tokens. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :ivar next_link: The URI that can be used to request the next list of tokens. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field + should be used to request the next list of tokens. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :keyword next_link: The URI that can be used to request the next list of tokens. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class TokenPassword(_serialization.Model): + """The password that will be used for authenticating the token of a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar creation_time: The creation datetime of the password. + :vartype creation_time: ~datetime.datetime + :ivar expiry: The expiry datetime of the password. + :vartype expiry: ~datetime.datetime + :ivar name: The password name "password1" or "password2". Known values are: "password1" and + "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenPasswordName + :ivar value: The password value. + :vartype value: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + creation_time: Optional[datetime.datetime] = None, + expiry: Optional[datetime.datetime] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, + **kwargs + ): + """ + :keyword creation_time: The creation datetime of the password. + :paramtype creation_time: ~datetime.datetime + :keyword expiry: The expiry datetime of the password. + :paramtype expiry: ~datetime.datetime + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenPasswordName + """ + super().__init__(**kwargs) + self.creation_time = creation_time + self.expiry = expiry + self.name = name + self.value = None + + +class TokenUpdateParameters(_serialization.Model): + """The parameters for updating a token. + + :ivar scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :vartype scope_map_id: str + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenStatus + :ivar credentials: The credentials that can be used for authenticating the token. + :vartype credentials: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCredentialsProperties + """ + + _attribute_map = { + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + } + + def __init__( + self, + *, + scope_map_id: Optional[str] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + **kwargs + ): + """ + :keyword scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :paramtype scope_map_id: str + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TokenStatus + :keyword credentials: The credentials that can be used for authenticating the token. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenCredentialsProperties + """ + super().__init__(**kwargs) + self.scope_map_id = scope_map_id + self.status = status + self.credentials = credentials + + +class TrustPolicy(_serialization.Model): + """The content trust policy for a container registry. + + :ivar type: The type of trust policy. "Notary" + :vartype type: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TrustPolicyType + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, + **kwargs + ): + """ + :keyword type: The type of trust policy. "Notary" + :paramtype type: str or ~azure.mgmt.containerregistry.v2022_12_01.models.TrustPolicyType + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.PolicyStatus + """ + super().__init__(**kwargs) + self.type = type + self.status = status + + +class UserIdentityProperties(_serialization.Model): + """UserIdentityProperties. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): + """ + :keyword principal_id: The principal id of user assigned identity. + :paramtype principal_id: str + :keyword client_id: The client id of user assigned identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.client_id = client_id + + +class Webhook(Resource): + """An object that represents a webhook for a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2022_12_01.models.SystemData + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + :ivar provisioning_state: The provisioning state of the webhook at the time the operation was + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2022_12_01.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.status = status + self.scope = scope + self.actions = actions + self.provisioning_state = None + + +class WebhookCreateParameters(_serialization.Model): + """The parameters for creating a webhook. + + All required parameters must be populated in order to send to Azure. + + :ivar tags: The tags for the webhook. + :vartype tags: dict[str, str] + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar service_uri: The service URI for the webhook to post notifications. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + """ + + _validation = { + "location": {"required": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + service_uri: Optional[str] = None, + custom_headers: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword tags: The tags for the webhook. + :paramtype tags: dict[str, str] + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword service_uri: The service URI for the webhook to post notifications. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.service_uri = service_uri + self.custom_headers = custom_headers + self.status = status + self.scope = scope + self.actions = actions + + +class WebhookListResult(_serialization.Model): + """The result of a request to list webhooks for a container registry. + + :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should + be used to request the next list of webhooks. + :vartype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :ivar next_link: The URI that can be used to request the next list of webhooks. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field + should be used to request the next list of webhooks. + :paramtype value: list[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :keyword next_link: The URI that can be used to request the next list of webhooks. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class WebhookUpdateParameters(_serialization.Model): + """The parameters for updating a webhook. + + :ivar tags: The tags for the webhook. + :vartype tags: dict[str, str] + :ivar service_uri: The service URI for the webhook to post notifications. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + service_uri: Optional[str] = None, + custom_headers: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword tags: The tags for the webhook. + :paramtype tags: dict[str, str] + :keyword service_uri: The service URI for the webhook to post notifications. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookAction] + """ + super().__init__(**kwargs) + self.tags = tags + self.service_uri = service_uri + self.custom_headers = custom_headers + self.status = status + self.scope = scope + self.actions = actions diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/__init__.py new file mode 100644 index 000000000000..f775bbfd22aa --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._registries_operations import RegistriesOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._replications_operations import ReplicationsOperations +from ._scope_maps_operations import ScopeMapsOperations +from ._tokens_operations import TokensOperations +from ._webhooks_operations import WebhooksOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "RegistriesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_operations.py new file mode 100644 index 000000000000..8d9fd24ef313 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_operations.py @@ -0,0 +1,159 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") + + # 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) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: + """Lists all of the available Azure Container Registry REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..f1014fead26e --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,754 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List all private endpoint connections in a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_12_01.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2022_12_01.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_registries_operations.py new file mode 100644 index 000000000000..621a80b70bac --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_registries_operations.py @@ -0,0 +1,2336 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_usages_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_private_link_resources_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_private_link_resource_request( + resource_group_name: str, registry_name: str, group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_credential_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _import_image_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters 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: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._import_image_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def check_name_availability( + self, + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: + """Lists all the container registries under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: + """Lists all the container registries under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: + """Gets the properties of the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _create_initial( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: _models.Registry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry=registry, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry_update_parameters=registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace + def list_usages( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: + """Gets the quota usages for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryUsageListResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) + + request = build_list_usages_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } + + @distributed_trace + def list_private_link_resources( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Lists the private link resources for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_link_resources_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } + + @distributed_trace + def get_private_link_resource( + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource by a specified group name for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param group_name: The name of the private link resource. Required. + :type group_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) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_private_link_resource_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } + + @distributed_trace + def list_credentials( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Lists the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Is either a model type or a IO type. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") + + request = build_regenerate_credential_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } + + def _generate_credentials_initial( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> Optional[_models.GenerateCredentialsResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters 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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._generate_credentials_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + generate_credentials_parameters=generate_credentials_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_replications_operations.py new file mode 100644 index 000000000000..cab0229719f5 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_replications_operations.py @@ -0,0 +1,1021 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: + """Lists all the replications for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Replication or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: + """Gets the properties of the specified replication. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Replication or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication=replication, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a replication from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication_update_parameters=replication_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_scope_maps_operations.py new file mode 100644 index 000000000000..59771dfffc71 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_scope_maps_operations.py @@ -0,0 +1,1024 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: + """Lists all the scope maps for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeMap or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ScopeMapListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: + """Gets the properties of the specified scope map. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeMap or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap 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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_create_parameters=scope_map_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a scope map from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters 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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_update_parameters=scope_map_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_tokens_operations.py new file mode 100644 index 000000000000..5f007935a0bc --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_tokens_operations.py @@ -0,0 +1,1017 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: + """Lists all the tokens for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Token or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TokenListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: + """Gets the properties of the specified token. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Token or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Token + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token + :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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token 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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_create_parameters=token_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a token from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters 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 Token or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_update_parameters=token_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_webhooks_operations.py new file mode 100644 index 000000000000..fa9882cd8f76 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_webhooks_operations.py @@ -0,0 +1,1345 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ping_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_events_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_callback_config_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2022_12_01.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: + """Lists all the webhooks for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WebhookListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: + """Gets the properties of the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Webhook or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Webhook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters 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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_create_parameters=webhook_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a webhook from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters 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 Webhook or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2022_12_01.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_update_parameters=webhook_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: + """Triggers a ping event to be sent to the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventInfo or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.EventInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) + + request = build_ping_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } + + @distributed_trace + def list_events( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: + """Lists recent events for the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2022_12_01.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_events_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } + + @distributed_trace + def get_callback_config( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: + """Gets the configuration of service URI and custom headers for the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallbackConfig or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.CallbackConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01")) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) + + request = build_get_callback_config_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CallbackConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/__init__.py new file mode 100644 index 000000000000..0e99a7bac3b7 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._container_registry_management_client import ContainerRegistryManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_configuration.py new file mode 100644 index 000000000000..e88ffdef111c --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ContainerRegistryManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2023-01-01-preview"] = kwargs.pop("api_version", "2023-01-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-containerregistry/{}".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.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 + ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_container_registry_management_client.py new file mode 100644 index 000000000000..043bb56e3e9c --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_container_registry_management_client.py @@ -0,0 +1,160 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import ContainerRegistryManagementClientConfiguration +from .operations import ( + CacheRulesOperations, + ConnectedRegistriesOperations, + CredentialSetsOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """ContainerRegistryManagementClient. + + :ivar cache_rules: CacheRulesOperations operations + :vartype cache_rules: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.CacheRulesOperations + :ivar connected_registries: ConnectedRegistriesOperations operations + :vartype connected_registries: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.ConnectedRegistriesOperations + :ivar credential_sets: CredentialSetsOperations operations + :vartype credential_sets: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.CredentialSetsOperations + :ivar export_pipelines: ExportPipelinesOperations operations + :vartype export_pipelines: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.ExportPipelinesOperations + :ivar registries: RegistriesOperations operations + :vartype registries: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.RegistriesOperations + :ivar import_pipelines: ImportPipelinesOperations operations + :vartype import_pipelines: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.ImportPipelinesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.containerregistry.v2023_01_01_preview.operations.Operations + :ivar pipeline_runs: PipelineRunsOperations operations + :vartype pipeline_runs: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.PipelineRunsOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.PrivateEndpointConnectionsOperations + :ivar replications: ReplicationsOperations operations + :vartype replications: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.ReplicationsOperations + :ivar scope_maps: ScopeMapsOperations operations + :vartype scope_maps: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.ScopeMapsOperations + :ivar tokens: TokensOperations operations + :vartype tokens: azure.mgmt.containerregistry.v2023_01_01_preview.operations.TokensOperations + :ivar webhooks: WebhooksOperations operations + :vartype webhooks: + azure.mgmt.containerregistry.v2023_01_01_preview.operations.WebhooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2023-01-01-preview". 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. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.cache_rules = CacheRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.credential_sets = CredentialSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + 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 + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "ContainerRegistryManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_metadata.json new file mode 100644 index 000000000000..d1122841fe35 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_metadata.json @@ -0,0 +1,114 @@ +{ + "chosen_version": "2023-01-01-preview", + "total_api_version_list": ["2023-01-01-preview"], + "client": { + "name": "ContainerRegistryManagementClient", + "filename": "_container_registry_management_client", + "description": "ContainerRegistryManagementClient.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "cache_rules": "CacheRulesOperations", + "connected_registries": "ConnectedRegistriesOperations", + "credential_sets": "CredentialSetsOperations", + "export_pipelines": "ExportPipelinesOperations", + "registries": "RegistriesOperations", + "import_pipelines": "ImportPipelinesOperations", + "operations": "Operations", + "pipeline_runs": "PipelineRunsOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "replications": "ReplicationsOperations", + "scope_maps": "ScopeMapsOperations", + "tokens": "TokensOperations", + "webhooks": "WebhooksOperations" + } +} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_vendor.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.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) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + 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] + template = "/".join(components) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/__init__.py new file mode 100644 index 000000000000..2b9f561654c9 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._container_registry_management_client import ContainerRegistryManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ContainerRegistryManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..697420616ce1 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ContainerRegistryManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ContainerRegistryManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ContainerRegistryManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2023-01-01-preview"] = kwargs.pop("api_version", "2023-01-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-containerregistry/{}".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") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_container_registry_management_client.py new file mode 100644 index 000000000000..26c82c626b08 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_container_registry_management_client.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import ContainerRegistryManagementClientConfiguration +from .operations import ( + CacheRulesOperations, + ConnectedRegistriesOperations, + CredentialSetsOperations, + ExportPipelinesOperations, + ImportPipelinesOperations, + Operations, + PipelineRunsOperations, + PrivateEndpointConnectionsOperations, + RegistriesOperations, + ReplicationsOperations, + ScopeMapsOperations, + TokensOperations, + WebhooksOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ContainerRegistryManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """ContainerRegistryManagementClient. + + :ivar cache_rules: CacheRulesOperations operations + :vartype cache_rules: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.CacheRulesOperations + :ivar connected_registries: ConnectedRegistriesOperations operations + :vartype connected_registries: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.ConnectedRegistriesOperations + :ivar credential_sets: CredentialSetsOperations operations + :vartype credential_sets: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.CredentialSetsOperations + :ivar export_pipelines: ExportPipelinesOperations operations + :vartype export_pipelines: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.ExportPipelinesOperations + :ivar registries: RegistriesOperations operations + :vartype registries: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.RegistriesOperations + :ivar import_pipelines: ImportPipelinesOperations operations + :vartype import_pipelines: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.ImportPipelinesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.Operations + :ivar pipeline_runs: PipelineRunsOperations operations + :vartype pipeline_runs: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.PipelineRunsOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations + :ivar replications: ReplicationsOperations operations + :vartype replications: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.ReplicationsOperations + :ivar scope_maps: ScopeMapsOperations operations + :vartype scope_maps: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.ScopeMapsOperations + :ivar tokens: TokensOperations operations + :vartype tokens: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.TokensOperations + :ivar webhooks: WebhooksOperations operations + :vartype webhooks: + azure.mgmt.containerregistry.v2023_01_01_preview.aio.operations.WebhooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2023-01-01-preview". 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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ContainerRegistryManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.cache_rules = CacheRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_registries = ConnectedRegistriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.credential_sets = CredentialSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_pipelines = ExportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.registries = RegistriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.import_pipelines = ImportPipelinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.pipeline_runs = PipelineRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.replications = ReplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_maps = ScopeMapsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + 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 + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ContainerRegistryManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..da883493d287 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/__init__.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._cache_rules_operations import CacheRulesOperations +from ._connected_registries_operations import ConnectedRegistriesOperations +from ._credential_sets_operations import CredentialSetsOperations +from ._export_pipelines_operations import ExportPipelinesOperations +from ._registries_operations import RegistriesOperations +from ._import_pipelines_operations import ImportPipelinesOperations +from ._operations import Operations +from ._pipeline_runs_operations import PipelineRunsOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._replications_operations import ReplicationsOperations +from ._scope_maps_operations import ScopeMapsOperations +from ._tokens_operations import TokensOperations +from ._webhooks_operations import WebhooksOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "CacheRulesOperations", + "ConnectedRegistriesOperations", + "CredentialSetsOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_cache_rules_operations.py new file mode 100644 index 000000000000..ac7eef39b3e1 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_cache_rules_operations.py @@ -0,0 +1,863 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._cache_rules_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CacheRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`cache_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.CacheRule"]: + """Lists all cache rule resources for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CacheRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CacheRulesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> _models.CacheRule: + """Gets the properties of the specified cache rule resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CacheRule or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: Union[_models.CacheRule, IO], + **kwargs: Any + ) -> _models.CacheRule: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cache_rule_create_parameters, (IO, bytes)): + _content = cache_rule_create_parameters + else: + _json = self._serialize.body(cache_rule_create_parameters, "CacheRule") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CacheRule", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: _models.CacheRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Required. + :type cache_rule_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule + :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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Required. + :type cache_rule_create_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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: Union[_models.CacheRule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Is either a + model type or a IO type. Required. + :type cache_rule_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule 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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + cache_rule_create_parameters=cache_rule_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CacheRule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a cache rule resource from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO], + **kwargs: Any + ) -> _models.CacheRule: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cache_rule_update_parameters, (IO, bytes)): + _content = cache_rule_update_parameters + else: + _json = self._serialize.body(cache_rule_update_parameters, "CacheRuleUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CacheRule", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: _models.CacheRuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Required. + :type cache_rule_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRuleUpdateParameters + :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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Required. + :type cache_rule_update_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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Is either a + model type or a IO type. Required. + :type cache_rule_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRuleUpdateParameters 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 CacheRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + cache_rule_update_parameters=cache_rule_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CacheRule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_connected_registries_operations.py new file mode 100644 index 000000000000..200850c01383 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_connected_registries_operations.py @@ -0,0 +1,1004 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._connected_registries_operations import ( + build_create_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedRegistry"]: + """Lists all connected registries for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param filter: An OData filter expression that describes a subset of connectedRegistries to + return. The parameters that can be filtered are parent.id (the resource id of the + connectedRegistry parent), mode, and connectionState. The supported operator is eq. Default + value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: + """Gets the properties of the connected registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedRegistry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], + **kwargs: Any + ) -> _models.ConnectedRegistry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry 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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + connected_registry_create_parameters=connected_registry_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a connected registry from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.ConnectedRegistry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryUpdateParameters 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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + connected_registry_update_parameters=connected_registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + async def _deactivate_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } + + @distributed_trace_async + async def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deactivates the connected registry instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._deactivate_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_credential_sets_operations.py new file mode 100644 index 000000000000..3ab1ba39fb4a --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_credential_sets_operations.py @@ -0,0 +1,869 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._credential_sets_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CredentialSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`credential_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CredentialSet"]: + """Lists all credential set resources for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CredentialSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CredentialSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> _models.CredentialSet: + """Gets the properties of the specified credential set resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CredentialSet or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: Union[_models.CredentialSet, IO], + **kwargs: Any + ) -> _models.CredentialSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(credential_set_create_parameters, (IO, bytes)): + _content = credential_set_create_parameters + else: + _json = self._serialize.body(credential_set_create_parameters, "CredentialSet") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: _models.CredentialSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. + Required. + :type credential_set_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet + :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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. + Required. + :type credential_set_create_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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: Union[_models.CredentialSet, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. Is + either a model type or a IO type. Required. + :type credential_set_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet 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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + credential_set_create_parameters=credential_set_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CredentialSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a credential set from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO], + **kwargs: Any + ) -> _models.CredentialSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(credential_set_update_parameters, (IO, bytes)): + _content = credential_set_update_parameters + else: + _json = self._serialize.body(credential_set_update_parameters, "CredentialSetUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: _models.CredentialSetUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. + Required. + :type credential_set_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSetUpdateParameters + :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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. + Required. + :type credential_set_update_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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. Is + either a model type or a IO type. Required. + :type credential_set_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSetUpdateParameters 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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + credential_set_update_parameters=credential_set_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CredentialSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_export_pipelines_operations.py new file mode 100644 index 000000000000..071f32750801 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_export_pipelines_operations.py @@ -0,0 +1,612 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._export_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExportPipeline"]: + """Lists all export pipelines for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExportPipeline or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: + """Gets the properties of the export pipeline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExportPipeline or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> _models.ExportPipeline: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + export_pipeline_create_parameters=export_pipeline_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ExportPipeline", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an export pipeline from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_import_pipelines_operations.py new file mode 100644 index 000000000000..2d686d7f82ce --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_import_pipelines_operations.py @@ -0,0 +1,612 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._import_pipelines_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportPipeline"]: + """Lists all import pipelines for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImportPipeline or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: + """Gets the properties of the import pipeline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImportPipeline or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> _models.ImportPipeline: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + import_pipeline_create_parameters=import_pipeline_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ImportPipeline", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an import pipeline from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..2b1172f1f452 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_operations.py @@ -0,0 +1,139 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: + """Lists all of the available Azure Container Registry REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_pipeline_runs_operations.py new file mode 100644 index 000000000000..586fc517a4f5 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_pipeline_runs_operations.py @@ -0,0 +1,608 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._pipeline_runs_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.PipelineRun"]: + """Lists all the pipeline runs for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PipelineRun or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PipelineRunListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: + """Gets the detailed information for a given pipeline run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineRun or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], + **kwargs: Any + ) -> _models.PipelineRun: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun 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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + pipeline_run_create_parameters=pipeline_run_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PipelineRun", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a pipeline run from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..5972061813c6 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,612 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +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, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List all private endpoint connections in a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2023_01_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2023_01_01_preview.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 + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_registries_operations.py new file mode 100644 index 000000000000..99efe8135177 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_registries_operations.py @@ -0,0 +1,1924 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._registries_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_generate_credentials_request, + build_get_private_link_resource_request, + build_get_request, + build_import_image_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_private_link_resources_request, + build_list_request, + build_list_usages_request, + build_regenerate_credential_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _import_image_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportImageParameters 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._import_image_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + async def check_name_availability( + self, + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: + """Lists all the container registries under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Registry"]: + """Lists all the container registries under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: + """Gets the properties of the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _create_initial( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: _models.Registry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry=registry, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUpdateParameters 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 Registry or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry_update_parameters=registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace_async + async def list_usages( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: + """Gets the quota usages for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryUsageListResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) + + request = build_list_usages_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } + + @distributed_trace + def list_private_link_resources( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Lists the private link resources for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_link_resources_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } + + @distributed_trace_async + async def get_private_link_resource( + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource by a specified group name for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param group_name: The name of the private link resource. Required. + :type group_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) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_private_link_resource_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } + + @distributed_trace_async + async def list_credentials( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Lists the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Is either a model type or a IO type. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") + + request = build_regenerate_credential_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } + + async def _generate_credentials_initial( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> Optional[_models.GenerateCredentialsResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsParameters 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 GenerateCredentialsResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._generate_credentials_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + generate_credentials_parameters=generate_credentials_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_replications_operations.py new file mode 100644 index 000000000000..db76db1f15ef --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_replications_operations.py @@ -0,0 +1,856 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._replications_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Replication"]: + """Lists all the replications for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Replication or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: + """Gets the properties of the specified replication. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Replication or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication=replication, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a replication from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ReplicationUpdateParameters 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication_update_parameters=replication_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_scope_maps_operations.py new file mode 100644 index 000000000000..7e21fe6f0f5f --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_scope_maps_operations.py @@ -0,0 +1,863 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._scope_maps_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.ScopeMap"]: + """Lists all the scope maps for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeMap or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ScopeMapListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> _models.ScopeMap: + """Gets the properties of the specified scope map. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeMap or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap 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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_create_parameters=scope_map_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a scope map from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMapUpdateParameters 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 ScopeMap or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_update_parameters=scope_map_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_tokens_operations.py new file mode 100644 index 000000000000..7df27f11e972 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_tokens_operations.py @@ -0,0 +1,854 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._tokens_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Token"]: + """Lists all the tokens for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Token or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TokenListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: + """Gets the properties of the specified token. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Token or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_create_parameters=token_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a token from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenUpdateParameters 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_update_parameters=token_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_webhooks_operations.py new file mode 100644 index 000000000000..43d3951292dc --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/aio/operations/_webhooks_operations.py @@ -0,0 +1,1093 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._webhooks_operations import ( + build_create_request, + build_delete_request, + build_get_callback_config_request, + build_get_request, + build_list_events_request, + build_list_request, + build_ping_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.aio.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> AsyncIterable["_models.Webhook"]: + """Lists all the webhooks for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WebhookListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.Webhook: + """Gets the properties of the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Webhook or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _create_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookCreateParameters 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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_create_parameters=webhook_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a webhook from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + async def _update_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookUpdateParameters 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 Webhook or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_update_parameters=webhook_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace_async + async def ping( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.EventInfo: + """Triggers a ping event to be sent to the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventInfo or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) + + request = build_ping_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } + + @distributed_trace + def list_events( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: + """Lists recent events for the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_events_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } + + @distributed_trace_async + async def get_callback_config( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: + """Gets the configuration of service URI and custom headers for the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallbackConfig or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CallbackConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) + + request = build_get_callback_config_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CallbackConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/__init__.py new file mode 100644 index 000000000000..988a5a937caf --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/__init__.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ActivationProperties +from ._models_py3 import ActiveDirectoryObject +from ._models_py3 import Actor +from ._models_py3 import AuthCredential +from ._models_py3 import AzureADAuthenticationAsArmPolicy +from ._models_py3 import CacheRule +from ._models_py3 import CacheRuleUpdateParameters +from ._models_py3 import CacheRulesListResult +from ._models_py3 import CallbackConfig +from ._models_py3 import ConnectedRegistry +from ._models_py3 import ConnectedRegistryListResult +from ._models_py3 import ConnectedRegistryUpdateParameters +from ._models_py3 import CredentialHealth +from ._models_py3 import CredentialSet +from ._models_py3 import CredentialSetListResult +from ._models_py3 import CredentialSetUpdateParameters +from ._models_py3 import EncryptionProperty +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import Event +from ._models_py3 import EventContent +from ._models_py3 import EventInfo +from ._models_py3 import EventListResult +from ._models_py3 import EventRequestMessage +from ._models_py3 import EventResponseMessage +from ._models_py3 import ExportPipeline +from ._models_py3 import ExportPipelineListResult +from ._models_py3 import ExportPipelineTargetProperties +from ._models_py3 import ExportPolicy +from ._models_py3 import GenerateCredentialsParameters +from ._models_py3 import GenerateCredentialsResult +from ._models_py3 import IPRule +from ._models_py3 import IdentityProperties +from ._models_py3 import ImportImageParameters +from ._models_py3 import ImportPipeline +from ._models_py3 import ImportPipelineListResult +from ._models_py3 import ImportPipelineSourceProperties +from ._models_py3 import ImportSource +from ._models_py3 import ImportSourceCredentials +from ._models_py3 import InnerErrorDescription +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LoggingProperties +from ._models_py3 import LoginServerProperties +from ._models_py3 import NetworkRuleSet +from ._models_py3 import OperationDefinition +from ._models_py3 import OperationDisplayDefinition +from ._models_py3 import OperationListResult +from ._models_py3 import OperationLogSpecificationDefinition +from ._models_py3 import OperationMetricSpecificationDefinition +from ._models_py3 import OperationServiceSpecificationDefinition +from ._models_py3 import PackageType +from ._models_py3 import ParentProperties +from ._models_py3 import PipelineRun +from ._models_py3 import PipelineRunListResult +from ._models_py3 import PipelineRunRequest +from ._models_py3 import PipelineRunResponse +from ._models_py3 import PipelineRunSourceProperties +from ._models_py3 import PipelineRunTargetProperties +from ._models_py3 import PipelineSourceTriggerDescriptor +from ._models_py3 import PipelineSourceTriggerProperties +from ._models_py3 import PipelineTriggerDescriptor +from ._models_py3 import PipelineTriggerProperties +from ._models_py3 import Policies +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProgressProperties +from ._models_py3 import ProxyResource +from ._models_py3 import QuarantinePolicy +from ._models_py3 import RegenerateCredentialParameters +from ._models_py3 import Registry +from ._models_py3 import RegistryListCredentialsResult +from ._models_py3 import RegistryListResult +from ._models_py3 import RegistryNameCheckRequest +from ._models_py3 import RegistryNameStatus +from ._models_py3 import RegistryPassword +from ._models_py3 import RegistryUpdateParameters +from ._models_py3 import RegistryUsage +from ._models_py3 import RegistryUsageListResult +from ._models_py3 import Replication +from ._models_py3 import ReplicationListResult +from ._models_py3 import ReplicationUpdateParameters +from ._models_py3 import Request +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import ScopeMap +from ._models_py3 import ScopeMapListResult +from ._models_py3 import ScopeMapUpdateParameters +from ._models_py3 import Sku +from ._models_py3 import SoftDeletePolicy +from ._models_py3 import Source +from ._models_py3 import Status +from ._models_py3 import StatusDetailProperties +from ._models_py3 import StorageAccountProperties +from ._models_py3 import SyncProperties +from ._models_py3 import SyncUpdateProperties +from ._models_py3 import SystemData +from ._models_py3 import Target +from ._models_py3 import TlsCertificateProperties +from ._models_py3 import TlsProperties +from ._models_py3 import Token +from ._models_py3 import TokenCertificate +from ._models_py3 import TokenCredentialsProperties +from ._models_py3 import TokenListResult +from ._models_py3 import TokenPassword +from ._models_py3 import TokenUpdateParameters +from ._models_py3 import TrustPolicy +from ._models_py3 import UserIdentityProperties +from ._models_py3 import Webhook +from ._models_py3 import WebhookCreateParameters +from ._models_py3 import WebhookListResult +from ._models_py3 import WebhookUpdateParameters + +from ._container_registry_management_client_enums import Action +from ._container_registry_management_client_enums import ActionsRequired +from ._container_registry_management_client_enums import ActivationStatus +from ._container_registry_management_client_enums import AuditLogStatus +from ._container_registry_management_client_enums import AzureADAuthenticationAsArmPolicyStatus +from ._container_registry_management_client_enums import CertificateType +from ._container_registry_management_client_enums import ConnectedRegistryMode +from ._container_registry_management_client_enums import ConnectionState +from ._container_registry_management_client_enums import ConnectionStatus +from ._container_registry_management_client_enums import CreatedByType +from ._container_registry_management_client_enums import CredentialHealthStatus +from ._container_registry_management_client_enums import CredentialName +from ._container_registry_management_client_enums import DefaultAction +from ._container_registry_management_client_enums import EncryptionStatus +from ._container_registry_management_client_enums import ExportPolicyStatus +from ._container_registry_management_client_enums import ImportMode +from ._container_registry_management_client_enums import LastModifiedByType +from ._container_registry_management_client_enums import LogLevel +from ._container_registry_management_client_enums import NetworkRuleBypassOptions +from ._container_registry_management_client_enums import PasswordName +from ._container_registry_management_client_enums import PipelineOptions +from ._container_registry_management_client_enums import PipelineRunSourceType +from ._container_registry_management_client_enums import PipelineRunTargetType +from ._container_registry_management_client_enums import PipelineSourceType +from ._container_registry_management_client_enums import PolicyStatus +from ._container_registry_management_client_enums import ProvisioningState +from ._container_registry_management_client_enums import PublicNetworkAccess +from ._container_registry_management_client_enums import RegistryUsageUnit +from ._container_registry_management_client_enums import ResourceIdentityType +from ._container_registry_management_client_enums import SkuName +from ._container_registry_management_client_enums import SkuTier +from ._container_registry_management_client_enums import TlsStatus +from ._container_registry_management_client_enums import TokenCertificateName +from ._container_registry_management_client_enums import TokenPasswordName +from ._container_registry_management_client_enums import TokenStatus +from ._container_registry_management_client_enums import TriggerStatus +from ._container_registry_management_client_enums import TrustPolicyType +from ._container_registry_management_client_enums import WebhookAction +from ._container_registry_management_client_enums import WebhookStatus +from ._container_registry_management_client_enums import ZoneRedundancy +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ActivationProperties", + "ActiveDirectoryObject", + "Actor", + "AuthCredential", + "AzureADAuthenticationAsArmPolicy", + "CacheRule", + "CacheRuleUpdateParameters", + "CacheRulesListResult", + "CallbackConfig", + "ConnectedRegistry", + "ConnectedRegistryListResult", + "ConnectedRegistryUpdateParameters", + "CredentialHealth", + "CredentialSet", + "CredentialSetListResult", + "CredentialSetUpdateParameters", + "EncryptionProperty", + "ErrorResponse", + "ErrorResponseBody", + "Event", + "EventContent", + "EventInfo", + "EventListResult", + "EventRequestMessage", + "EventResponseMessage", + "ExportPipeline", + "ExportPipelineListResult", + "ExportPipelineTargetProperties", + "ExportPolicy", + "GenerateCredentialsParameters", + "GenerateCredentialsResult", + "IPRule", + "IdentityProperties", + "ImportImageParameters", + "ImportPipeline", + "ImportPipelineListResult", + "ImportPipelineSourceProperties", + "ImportSource", + "ImportSourceCredentials", + "InnerErrorDescription", + "KeyVaultProperties", + "LoggingProperties", + "LoginServerProperties", + "NetworkRuleSet", + "OperationDefinition", + "OperationDisplayDefinition", + "OperationListResult", + "OperationLogSpecificationDefinition", + "OperationMetricSpecificationDefinition", + "OperationServiceSpecificationDefinition", + "PackageType", + "ParentProperties", + "PipelineRun", + "PipelineRunListResult", + "PipelineRunRequest", + "PipelineRunResponse", + "PipelineRunSourceProperties", + "PipelineRunTargetProperties", + "PipelineSourceTriggerDescriptor", + "PipelineSourceTriggerProperties", + "PipelineTriggerDescriptor", + "PipelineTriggerProperties", + "Policies", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProgressProperties", + "ProxyResource", + "QuarantinePolicy", + "RegenerateCredentialParameters", + "Registry", + "RegistryListCredentialsResult", + "RegistryListResult", + "RegistryNameCheckRequest", + "RegistryNameStatus", + "RegistryPassword", + "RegistryUpdateParameters", + "RegistryUsage", + "RegistryUsageListResult", + "Replication", + "ReplicationListResult", + "ReplicationUpdateParameters", + "Request", + "Resource", + "RetentionPolicy", + "ScopeMap", + "ScopeMapListResult", + "ScopeMapUpdateParameters", + "Sku", + "SoftDeletePolicy", + "Source", + "Status", + "StatusDetailProperties", + "StorageAccountProperties", + "SyncProperties", + "SyncUpdateProperties", + "SystemData", + "Target", + "TlsCertificateProperties", + "TlsProperties", + "Token", + "TokenCertificate", + "TokenCredentialsProperties", + "TokenListResult", + "TokenPassword", + "TokenUpdateParameters", + "TrustPolicy", + "UserIdentityProperties", + "Webhook", + "WebhookCreateParameters", + "WebhookListResult", + "WebhookUpdateParameters", + "Action", + "ActionsRequired", + "ActivationStatus", + "AuditLogStatus", + "AzureADAuthenticationAsArmPolicyStatus", + "CertificateType", + "ConnectedRegistryMode", + "ConnectionState", + "ConnectionStatus", + "CreatedByType", + "CredentialHealthStatus", + "CredentialName", + "DefaultAction", + "EncryptionStatus", + "ExportPolicyStatus", + "ImportMode", + "LastModifiedByType", + "LogLevel", + "NetworkRuleBypassOptions", + "PasswordName", + "PipelineOptions", + "PipelineRunSourceType", + "PipelineRunTargetType", + "PipelineSourceType", + "PolicyStatus", + "ProvisioningState", + "PublicNetworkAccess", + "RegistryUsageUnit", + "ResourceIdentityType", + "SkuName", + "SkuTier", + "TlsStatus", + "TokenCertificateName", + "TokenPasswordName", + "TokenStatus", + "TriggerStatus", + "TrustPolicyType", + "WebhookAction", + "WebhookStatus", + "ZoneRedundancy", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_container_registry_management_client_enums.py new file mode 100644 index 000000000000..72e0d43518a1 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_container_registry_management_client_enums.py @@ -0,0 +1,313 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of IP ACL rule.""" + + ALLOW = "Allow" + + +class ActionsRequired(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A message indicating if changes on the service provider require any updates on the consumer.""" + + NONE = "None" + RECREATE = "Recreate" + + +class ActivationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The activation status of the connected registry.""" + + ACTIVE = "Active" + INACTIVE = "Inactive" + + +class AuditLogStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether audit logs are enabled on the connected registry.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class AzureADAuthenticationAsArmPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of certificate location.""" + + LOCAL_DIRECTORY = "LocalDirectory" + + +class ConnectedRegistryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the connected registry resource that indicates the permissions of the registry.""" + + READ_WRITE = "ReadWrite" + READ_ONLY = "ReadOnly" + REGISTRY = "Registry" + MIRROR = "Mirror" + + +class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current connection state of the connected registry.""" + + ONLINE = "Online" + OFFLINE = "Offline" + SYNCING = "Syncing" + UNHEALTHY = "Unhealthy" + + +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link service connection status.""" + + APPROVED = "Approved" + PENDING = "Pending" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CredentialHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The health status of credential.""" + + HEALTHY = "Healthy" + UNHEALTHY = "Unhealthy" + + +class CredentialName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the credential.""" + + CREDENTIAL1 = "Credential1" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action of allow or deny when no other rules match.""" + + ALLOW = "Allow" + DENY = "Deny" + + +class EncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not the encryption is enabled for container registry.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ExportPolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ImportMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When Force, any existing target tags will be overwritten. When NoForce, any existing target + tags will fail the operation before any copying begins. + """ + + NO_FORCE = "NoForce" + FORCE = "Force" + + +class LastModifiedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that last modified the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The verbosity of logs persisted on the connected registry.""" + + DEBUG = "Debug" + INFORMATION = "Information" + WARNING = "Warning" + ERROR = "Error" + NONE = "None" + + +class NetworkRuleBypassOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to allow trusted Azure services to access a network restricted registry.""" + + AZURE_SERVICES = "AzureServices" + NONE = "None" + + +class PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name.""" + + PASSWORD = "password" + PASSWORD2 = "password2" + + +class PipelineOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PipelineOptions.""" + + OVERWRITE_TAGS = "OverwriteTags" + OVERWRITE_BLOBS = "OverwriteBlobs" + DELETE_SOURCE_BLOB_ON_SUCCESS = "DeleteSourceBlobOnSuccess" + CONTINUE_ON_ERRORS = "ContinueOnErrors" + + +class PipelineRunSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the source.""" + + AZURE_STORAGE_BLOB = "AzureStorageBlob" + + +class PipelineRunTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the target.""" + + AZURE_STORAGE_BLOB = "AzureStorageBlob" + + +class PipelineSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of source for the import pipeline.""" + + AZURE_STORAGE_BLOB_CONTAINER = "AzureStorageBlobContainer" + + +class PolicyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value that indicates whether the policy is enabled or not.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public network access is allowed for the container registry.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" + + COUNT = "Count" + BYTES = "Bytes" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name of the container registry. Required for registry creation.""" + + CLASSIC = "Classic" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" + + CLASSIC = "Classic" + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + + +class TlsStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether HTTPS is enabled for the login server.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class TokenCertificateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TokenCertificateName.""" + + CERTIFICATE1 = "certificate1" + CERTIFICATE2 = "certificate2" + + +class TokenPasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The password name "password1" or "password2".""" + + PASSWORD1 = "password1" + PASSWORD2 = "password2" + + +class TokenStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the token example enabled or disabled.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the source trigger.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class TrustPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of trust policy.""" + + NOTARY = "Notary" + + +class WebhookAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WebhookAction.""" + + PUSH = "push" + DELETE = "delete" + QUARANTINE = "quarantine" + CHART_PUSH = "chart_push" + CHART_DELETE = "chart_delete" + + +class WebhookStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the webhook at the time the operation was called.""" + + ENABLED = "enabled" + DISABLED = "disabled" + + +class ZoneRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not zone redundancy is enabled for this container registry.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..537307ba9336 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_models_py3.py @@ -0,0 +1,5317 @@ +# 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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ActivationProperties(_serialization.Model): + """The activation properties of the connected registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The activation status of the connected registry. Known values are: "Active" and + "Inactive". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ActivationStatus + """ + + _validation = { + "status": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.status = None + + +class ActiveDirectoryObject(_serialization.Model): + """The Active Directory Object that will be used for authenticating the token of a container registry. + + :ivar object_id: The user/group/application object ID for Active Directory Object that will be + used for authenticating the token of a container registry. + :vartype object_id: str + :ivar tenant_id: The tenant ID of user/group/application object Active Directory Object that + will be used for authenticating the token of a container registry. + :vartype tenant_id: str + """ + + _attribute_map = { + "object_id": {"key": "objectId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, *, object_id: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs): + """ + :keyword object_id: The user/group/application object ID for Active Directory Object that will + be used for authenticating the token of a container registry. + :paramtype object_id: str + :keyword tenant_id: The tenant ID of user/group/application object Active Directory Object that + will be used for authenticating the token of a container registry. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) + self.object_id = object_id + self.tenant_id = tenant_id + + +class Actor(_serialization.Model): + """The agent that initiated the event. For most situations, this could be from the authorization context of the request. + + :ivar name: The subject or username associated with the request context that generated the + event. + :vartype name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The subject or username associated with the request context that generated the + event. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class AuthCredential(_serialization.Model): + """Authentication credential stored for an upstream. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the credential. "Credential1" + :vartype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialName + :ivar username_secret_identifier: KeyVault Secret URI for accessing the username. + :vartype username_secret_identifier: str + :ivar password_secret_identifier: KeyVault Secret URI for accessing the password. + :vartype password_secret_identifier: str + :ivar credential_health: This provides data pertaining to the health of the auth credential. + :vartype credential_health: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialHealth + """ + + _validation = { + "credential_health": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "username_secret_identifier": {"key": "usernameSecretIdentifier", "type": "str"}, + "password_secret_identifier": {"key": "passwordSecretIdentifier", "type": "str"}, + "credential_health": {"key": "credentialHealth", "type": "CredentialHealth"}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "_models.CredentialName"]] = None, + username_secret_identifier: Optional[str] = None, + password_secret_identifier: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the credential. "Credential1" + :paramtype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialName + :keyword username_secret_identifier: KeyVault Secret URI for accessing the username. + :paramtype username_secret_identifier: str + :keyword password_secret_identifier: KeyVault Secret URI for accessing the password. + :paramtype password_secret_identifier: str + """ + super().__init__(**kwargs) + self.name = name + self.username_secret_identifier = username_secret_identifier + self.password_secret_identifier = password_secret_identifier + self.credential_health = None + + +class AzureADAuthenticationAsArmPolicy(_serialization.Model): + """The policy for using ARM audience token for a container registry. + + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AzureADAuthenticationAsArmPolicyStatus + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Union[str, "_models.AzureADAuthenticationAsArmPolicyStatus"] = "enabled", **kwargs): + """ + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AzureADAuthenticationAsArmPolicyStatus + """ + super().__init__(**kwargs) + self.status = status + + +class ProxyResource(_serialization.Model): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + """ + + _validation = { + "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"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class CacheRule(ProxyResource): + """An object that represents a cache rule for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar credential_set_resource_id: The ARM resource ID of the credential store which is + associated with the cache rule. + :vartype credential_set_resource_id: str + :ivar source_repository: Source repository pulled from upstream. + :vartype source_repository: str + :ivar target_repository: Target repository specified in docker pull command. + Eg: docker pull myregistry.azurecr.io/{targetRepository}:{tag}. + :vartype target_repository: str + :ivar creation_date: The creation date of the cache rule. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "credential_set_resource_id": {"key": "properties.credentialSetResourceId", "type": "str"}, + "source_repository": {"key": "properties.sourceRepository", "type": "str"}, + "target_repository": {"key": "properties.targetRepository", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + credential_set_resource_id: Optional[str] = None, + source_repository: Optional[str] = None, + target_repository: Optional[str] = None, + **kwargs + ): + """ + :keyword credential_set_resource_id: The ARM resource ID of the credential store which is + associated with the cache rule. + :paramtype credential_set_resource_id: str + :keyword source_repository: Source repository pulled from upstream. + :paramtype source_repository: str + :keyword target_repository: Target repository specified in docker pull command. + Eg: docker pull myregistry.azurecr.io/{targetRepository}:{tag}. + :paramtype target_repository: str + """ + super().__init__(**kwargs) + self.credential_set_resource_id = credential_set_resource_id + self.source_repository = source_repository + self.target_repository = target_repository + self.creation_date = None + self.provisioning_state = None + + +class CacheRulesListResult(_serialization.Model): + """The result of a request to list cache rules for a container registry. + + :ivar value: The list of cache rules. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :ivar next_link: If provided, client must use NextLink URI to request next list of cache rules. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CacheRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.CacheRule"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of cache rules. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :keyword next_link: If provided, client must use NextLink URI to request next list of cache + rules. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CacheRuleUpdateParameters(_serialization.Model): + """The parameters for updating a cache rule. + + :ivar credential_set_resource_id: The ARM resource ID of the credential store which is + associated with the Cache rule. + :vartype credential_set_resource_id: str + """ + + _attribute_map = { + "credential_set_resource_id": {"key": "properties.credentialSetResourceId", "type": "str"}, + } + + def __init__(self, *, credential_set_resource_id: Optional[str] = None, **kwargs): + """ + :keyword credential_set_resource_id: The ARM resource ID of the credential store which is + associated with the Cache rule. + :paramtype credential_set_resource_id: str + """ + super().__init__(**kwargs) + self.credential_set_resource_id = credential_set_resource_id + + +class CallbackConfig(_serialization.Model): + """The configuration of service URI and custom headers for the webhook. + + All required parameters must be populated in order to send to Azure. + + :ivar service_uri: The service URI for the webhook to post notifications. Required. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + """ + + _validation = { + "service_uri": {"required": True}, + } + + _attribute_map = { + "service_uri": {"key": "serviceUri", "type": "str"}, + "custom_headers": {"key": "customHeaders", "type": "{str}"}, + } + + def __init__(self, *, service_uri: str, custom_headers: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword service_uri: The service URI for the webhook to post notifications. Required. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + """ + super().__init__(**kwargs) + self.service_uri = service_uri + self.custom_headers = custom_headers + + +class ConnectedRegistry(ProxyResource): # pylint: disable=too-many-instance-attributes + """An object that represents a connected registry for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar mode: The mode of the connected registry resource that indicates the permissions of the + registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". + :vartype mode: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryMode + :ivar version: The current version of ACR runtime on the connected registry. + :vartype version: str + :ivar connection_state: The current connection state of the connected registry. Known values + are: "Online", "Offline", "Syncing", and "Unhealthy". + :vartype connection_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectionState + :ivar last_activity_time: The last activity time of the connected registry. + :vartype last_activity_time: ~datetime.datetime + :ivar activation: The activation properties of the connected registry. + :vartype activation: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ActivationProperties + :ivar parent: The parent of the connected registry. + :vartype parent: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ParentProperties + :ivar client_token_ids: The list of the ACR token resource IDs used to authenticate clients to + the connected registry. + :vartype client_token_ids: list[str] + :ivar login_server: The login server properties of the connected registry. + :vartype login_server: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoginServerProperties + :ivar logging: The logging properties of the connected registry. + :vartype logging: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoggingProperties + :ivar status_details: The list of current statuses of the connected registry. + :vartype status_details: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.StatusDetailProperties] + :ivar notifications_list: The list of notifications subscription information for the connected + registry. + :vartype notifications_list: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "version": {"readonly": True}, + "connection_state": {"readonly": True}, + "last_activity_time": {"readonly": True}, + "activation": {"readonly": True}, + "status_details": {"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"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "connection_state": {"key": "properties.connectionState", "type": "str"}, + "last_activity_time": {"key": "properties.lastActivityTime", "type": "iso-8601"}, + "activation": {"key": "properties.activation", "type": "ActivationProperties"}, + "parent": {"key": "properties.parent", "type": "ParentProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "login_server": {"key": "properties.loginServer", "type": "LoginServerProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "status_details": {"key": "properties.statusDetails", "type": "[StatusDetailProperties]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.ConnectedRegistryMode"]] = None, + parent: Optional["_models.ParentProperties"] = None, + client_token_ids: Optional[List[str]] = None, + login_server: Optional["_models.LoginServerProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, + notifications_list: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword mode: The mode of the connected registry resource that indicates the permissions of + the registry. Known values are: "ReadWrite", "ReadOnly", "Registry", and "Mirror". + :paramtype mode: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryMode + :keyword parent: The parent of the connected registry. + :paramtype parent: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ParentProperties + :keyword client_token_ids: The list of the ACR token resource IDs used to authenticate clients + to the connected registry. + :paramtype client_token_ids: list[str] + :keyword login_server: The login server properties of the connected registry. + :paramtype login_server: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoginServerProperties + :keyword logging: The logging properties of the connected registry. + :paramtype logging: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoggingProperties + :keyword notifications_list: The list of notifications subscription information for the + connected registry. + :paramtype notifications_list: list[str] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.mode = mode + self.version = None + self.connection_state = None + self.last_activity_time = None + self.activation = None + self.parent = parent + self.client_token_ids = client_token_ids + self.login_server = login_server + self.logging = logging + self.status_details = None + self.notifications_list = notifications_list + + +class ConnectedRegistryListResult(_serialization.Model): + """The result of a request to list connected registries for a container registry. + + :ivar value: The list of connected registries. Since this list may be incomplete, the nextLink + field should be used to request the next list of connected registries. + :vartype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :ivar next_link: The URI that can be used to request the next list of connected registries. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConnectedRegistry]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ConnectedRegistry"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of connected registries. Since this list may be incomplete, the + nextLink field should be used to request the next list of connected registries. + :paramtype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :keyword next_link: The URI that can be used to request the next list of connected registries. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ConnectedRegistryUpdateParameters(_serialization.Model): + """The parameters for updating a connected registry. + + :ivar sync_properties: The sync properties of the connected registry with its parent. + :vartype sync_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SyncUpdateProperties + :ivar logging: The logging properties of the connected registry. + :vartype logging: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoggingProperties + :ivar client_token_ids: The list of the ACR token resource IDs used to authenticate clients to + the connected registry. + :vartype client_token_ids: list[str] + :ivar notifications_list: The list of notifications subscription information for the connected + registry. + :vartype notifications_list: list[str] + """ + + _attribute_map = { + "sync_properties": {"key": "properties.syncProperties", "type": "SyncUpdateProperties"}, + "logging": {"key": "properties.logging", "type": "LoggingProperties"}, + "client_token_ids": {"key": "properties.clientTokenIds", "type": "[str]"}, + "notifications_list": {"key": "properties.notificationsList", "type": "[str]"}, + } + + def __init__( + self, + *, + sync_properties: Optional["_models.SyncUpdateProperties"] = None, + logging: Optional["_models.LoggingProperties"] = None, + client_token_ids: Optional[List[str]] = None, + notifications_list: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword sync_properties: The sync properties of the connected registry with its parent. + :paramtype sync_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SyncUpdateProperties + :keyword logging: The logging properties of the connected registry. + :paramtype logging: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LoggingProperties + :keyword client_token_ids: The list of the ACR token resource IDs used to authenticate clients + to the connected registry. + :paramtype client_token_ids: list[str] + :keyword notifications_list: The list of notifications subscription information for the + connected registry. + :paramtype notifications_list: list[str] + """ + super().__init__(**kwargs) + self.sync_properties = sync_properties + self.logging = logging + self.client_token_ids = client_token_ids + self.notifications_list = notifications_list + + +class CredentialHealth(_serialization.Model): + """The health of the auth credential. + + :ivar status: The health status of credential. Known values are: "Healthy" and "Unhealthy". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialHealthStatus + :ivar error_code: Error code representing the health check error. + :vartype error_code: str + :ivar error_message: Descriptive message representing the health check error. + :vartype error_message: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.CredentialHealthStatus"]] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): + """ + :keyword status: The health status of credential. Known values are: "Healthy" and "Unhealthy". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialHealthStatus + :keyword error_code: Error code representing the health check error. + :paramtype error_code: str + :keyword error_message: Descriptive message representing the health check error. + :paramtype error_message: str + """ + super().__init__(**kwargs) + self.status = status + self.error_code = error_code + self.error_message = error_message + + +class CredentialSet(ProxyResource): + """An object that represents a credential set resource for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar identity: Identities associated with the resource. This is used to access the KeyVault + secrets. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar login_server: The credentials are stored for this upstream or login server. + :vartype login_server: str + :ivar auth_credentials: List of authentication credentials stored for an upstream. + Usually consists of a primary and an optional secondary credential. + :vartype auth_credentials: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuthCredential] + :ivar creation_date: The creation date of credential store resource. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "auth_credentials": {"key": "properties.authCredentials", "type": "[AuthCredential]"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + identity: Optional["_models.IdentityProperties"] = None, + login_server: Optional[str] = None, + auth_credentials: Optional[List["_models.AuthCredential"]] = None, + **kwargs + ): + """ + :keyword identity: Identities associated with the resource. This is used to access the KeyVault + secrets. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword login_server: The credentials are stored for this upstream or login server. + :paramtype login_server: str + :keyword auth_credentials: List of authentication credentials stored for an upstream. + Usually consists of a primary and an optional secondary credential. + :paramtype auth_credentials: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuthCredential] + """ + super().__init__(**kwargs) + self.identity = identity + self.login_server = login_server + self.auth_credentials = auth_credentials + self.creation_date = None + self.provisioning_state = None + + +class CredentialSetListResult(_serialization.Model): + """The result of a request to list credential sets for a container registry. + + :ivar value: The list of credential sets. Since this list may be incomplete, the nextLink field + should be used to request the next list of credential sets. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :ivar next_link: The URI that can be used to request the next list of credential sets. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CredentialSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CredentialSet"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of credential sets. Since this list may be incomplete, the nextLink + field should be used to request the next list of credential sets. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :keyword next_link: The URI that can be used to request the next list of credential sets. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CredentialSetUpdateParameters(_serialization.Model): + """The parameters for updating a credential set. + + :ivar identity: Identities associated with the resource. This is used to access the KeyVault + secrets. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar auth_credentials: List of authentication credentials stored for an upstream. + Usually consists of a primary and an optional secondary credential. + :vartype auth_credentials: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuthCredential] + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "IdentityProperties"}, + "auth_credentials": {"key": "properties.authCredentials", "type": "[AuthCredential]"}, + } + + def __init__( + self, + *, + identity: Optional["_models.IdentityProperties"] = None, + auth_credentials: Optional[List["_models.AuthCredential"]] = None, + **kwargs + ): + """ + :keyword identity: Identities associated with the resource. This is used to access the KeyVault + secrets. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword auth_credentials: List of authentication credentials stored for an upstream. + Usually consists of a primary and an optional secondary credential. + :paramtype auth_credentials: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuthCredential] + """ + super().__init__(**kwargs) + self.identity = identity + self.auth_credentials = auth_credentials + + +class EncryptionProperty(_serialization.Model): + """EncryptionProperty. + + :ivar status: Indicates whether or not the encryption is enabled for container registry. Known + values are: "enabled" and "disabled". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionStatus + :ivar key_vault_properties: Key vault properties. + :vartype key_vault_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.KeyVaultProperties + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.EncryptionStatus"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + **kwargs + ): + """ + :keyword status: Indicates whether or not the encryption is enabled for container registry. + Known values are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionStatus + :keyword key_vault_properties: Key vault properties. + :paramtype key_vault_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.KeyVaultProperties + """ + super().__init__(**kwargs) + self.status = status + self.key_vault_properties = key_vault_properties + + +class ErrorResponse(_serialization.Model): + """An error response from the Azure Container Registry service. + + :ivar error: Azure container registry build API error body. + :vartype error: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ErrorResponseBody + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseBody"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): + """ + :keyword error: Azure container registry build API error body. + :paramtype error: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ErrorResponseBody + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseBody(_serialization.Model): + """An error response from the Azure Container Registry service. + + All required parameters must be populated in order to send to Azure. + + :ivar code: error code. Required. + :vartype code: str + :ivar message: error message. Required. + :vartype message: str + :ivar target: target of the particular error. + :vartype target: str + :ivar details: an array of additional nested error response info objects, as described by this + contract. + :vartype details: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.InnerErrorDescription] + """ + + _validation = { + "code": {"required": True}, + "message": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[InnerErrorDescription]"}, + } + + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + details: Optional[List["_models.InnerErrorDescription"]] = None, + **kwargs + ): + """ + :keyword code: error code. Required. + :paramtype code: str + :keyword message: error message. Required. + :paramtype message: str + :keyword target: target of the particular error. + :paramtype target: str + :keyword details: an array of additional nested error response info objects, as described by + this contract. + :paramtype details: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.InnerErrorDescription] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class EventInfo(_serialization.Model): + """The basic information of an event. + + :ivar id: The event ID. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The event ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class Event(EventInfo): + """The event for a webhook. + + :ivar id: The event ID. + :vartype id: str + :ivar event_request_message: The event request message sent to the service URI. + :vartype event_request_message: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventRequestMessage + :ivar event_response_message: The event response message received from the service URI. + :vartype event_response_message: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventResponseMessage + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "event_request_message": {"key": "eventRequestMessage", "type": "EventRequestMessage"}, + "event_response_message": {"key": "eventResponseMessage", "type": "EventResponseMessage"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + event_request_message: Optional["_models.EventRequestMessage"] = None, + event_response_message: Optional["_models.EventResponseMessage"] = None, + **kwargs + ): + """ + :keyword id: The event ID. + :paramtype id: str + :keyword event_request_message: The event request message sent to the service URI. + :paramtype event_request_message: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventRequestMessage + :keyword event_response_message: The event response message received from the service URI. + :paramtype event_response_message: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventResponseMessage + """ + super().__init__(id=id, **kwargs) + self.event_request_message = event_request_message + self.event_response_message = event_response_message + + +class EventContent(_serialization.Model): + """The content of the event request message. + + :ivar id: The event ID. + :vartype id: str + :ivar timestamp: The time at which the event occurred. + :vartype timestamp: ~datetime.datetime + :ivar action: The action that encompasses the provided event. + :vartype action: str + :ivar target: The target of the event. + :vartype target: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Target + :ivar request: The request that generated the event. + :vartype request: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Request + :ivar actor: The agent that initiated the event. For most situations, this could be from the + authorization context of the request. + :vartype actor: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Actor + :ivar source: The registry node that generated the event. Put differently, while the actor + initiates the event, the source generates it. + :vartype source: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Source + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "action": {"key": "action", "type": "str"}, + "target": {"key": "target", "type": "Target"}, + "request": {"key": "request", "type": "Request"}, + "actor": {"key": "actor", "type": "Actor"}, + "source": {"key": "source", "type": "Source"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + timestamp: Optional[datetime.datetime] = None, + action: Optional[str] = None, + target: Optional["_models.Target"] = None, + request: Optional["_models.Request"] = None, + actor: Optional["_models.Actor"] = None, + source: Optional["_models.Source"] = None, + **kwargs + ): + """ + :keyword id: The event ID. + :paramtype id: str + :keyword timestamp: The time at which the event occurred. + :paramtype timestamp: ~datetime.datetime + :keyword action: The action that encompasses the provided event. + :paramtype action: str + :keyword target: The target of the event. + :paramtype target: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Target + :keyword request: The request that generated the event. + :paramtype request: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Request + :keyword actor: The agent that initiated the event. For most situations, this could be from the + authorization context of the request. + :paramtype actor: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Actor + :keyword source: The registry node that generated the event. Put differently, while the actor + initiates the event, the source generates it. + :paramtype source: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Source + """ + super().__init__(**kwargs) + self.id = id + self.timestamp = timestamp + self.action = action + self.target = target + self.request = request + self.actor = actor + self.source = source + + +class EventListResult(_serialization.Model): + """The result of a request to list events for a webhook. + + :ivar value: The list of events. Since this list may be incomplete, the nextLink field should + be used to request the next list of events. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Event] + :ivar next_link: The URI that can be used to request the next list of events. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Event"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of events. Since this list may be incomplete, the nextLink field + should be used to request the next list of events. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Event] + :keyword next_link: The URI that can be used to request the next list of events. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class EventRequestMessage(_serialization.Model): + """The event request message sent to the service URI. + + :ivar content: The content of the event request message. + :vartype content: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventContent + :ivar headers: The headers of the event request message. + :vartype headers: dict[str, str] + :ivar method: The HTTP method used to send the event request message. + :vartype method: str + :ivar request_uri: The URI used to send the event request message. + :vartype request_uri: str + :ivar version: The HTTP message version. + :vartype version: str + """ + + _attribute_map = { + "content": {"key": "content", "type": "EventContent"}, + "headers": {"key": "headers", "type": "{str}"}, + "method": {"key": "method", "type": "str"}, + "request_uri": {"key": "requestUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + content: Optional["_models.EventContent"] = None, + headers: Optional[Dict[str, str]] = None, + method: Optional[str] = None, + request_uri: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword content: The content of the event request message. + :paramtype content: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventContent + :keyword headers: The headers of the event request message. + :paramtype headers: dict[str, str] + :keyword method: The HTTP method used to send the event request message. + :paramtype method: str + :keyword request_uri: The URI used to send the event request message. + :paramtype request_uri: str + :keyword version: The HTTP message version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.content = content + self.headers = headers + self.method = method + self.request_uri = request_uri + self.version = version + + +class EventResponseMessage(_serialization.Model): + """The event response message received from the service URI. + + :ivar content: The content of the event response message. + :vartype content: str + :ivar headers: The headers of the event response message. + :vartype headers: dict[str, str] + :ivar reason_phrase: The reason phrase of the event response message. + :vartype reason_phrase: str + :ivar status_code: The status code of the event response message. + :vartype status_code: str + :ivar version: The HTTP message version. + :vartype version: str + """ + + _attribute_map = { + "content": {"key": "content", "type": "str"}, + "headers": {"key": "headers", "type": "{str}"}, + "reason_phrase": {"key": "reasonPhrase", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + content: Optional[str] = None, + headers: Optional[Dict[str, str]] = None, + reason_phrase: Optional[str] = None, + status_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword content: The content of the event response message. + :paramtype content: str + :keyword headers: The headers of the event response message. + :paramtype headers: dict[str, str] + :keyword reason_phrase: The reason phrase of the event response message. + :paramtype reason_phrase: str + :keyword status_code: The status code of the event response message. + :paramtype status_code: str + :keyword version: The HTTP message version. + :paramtype version: str + """ + super().__init__(**kwargs) + self.content = content + self.headers = headers + self.reason_phrase = reason_phrase + self.status_code = status_code + self.version = version + + +class ExportPipeline(ProxyResource): + """An object that represents an export pipeline for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar location: The location of the export pipeline. + :vartype location: str + :ivar identity: The identity of the export pipeline. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar target: The target properties of the export pipeline. + :vartype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipelineTargetProperties + :ivar options: The list of all options configured for the pipeline. + :vartype options: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineOptions] + :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "target": {"key": "properties.target", "type": "ExportPipelineTargetProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + identity: Optional["_models.IdentityProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, + **kwargs + ): + """ + :keyword location: The location of the export pipeline. + :paramtype location: str + :keyword identity: The identity of the export pipeline. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword target: The target properties of the export pipeline. + :paramtype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipelineTargetProperties + :keyword options: The list of all options configured for the pipeline. + :paramtype options: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineOptions] + """ + super().__init__(**kwargs) + self.location = location + self.identity = identity + self.target = target + self.options = options + self.provisioning_state = None + + +class ExportPipelineListResult(_serialization.Model): + """The result of a request to list export pipelines for a container registry. + + :ivar value: The list of export pipelines. Since this list may be incomplete, the nextLink + field should be used to request the next list of export pipelines. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :ivar next_link: The URI that can be used to request the next list of pipeline runs. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ExportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ExportPipeline"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of export pipelines. Since this list may be incomplete, the nextLink + field should be used to request the next list of export pipelines. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :keyword next_link: The URI that can be used to request the next list of pipeline runs. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ExportPipelineTargetProperties(_serialization.Model): + """The properties of the export pipeline target. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of target for the export pipeline. + :vartype type: str + :ivar uri: The target uri of the export pipeline. + When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" + When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". + :vartype uri: str + :ivar key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. + :vartype key_vault_uri: str + """ + + _validation = { + "key_vault_uri": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + } + + def __init__(self, *, key_vault_uri: str, type: Optional[str] = None, uri: Optional[str] = None, **kwargs): + """ + :keyword type: The type of target for the export pipeline. + :paramtype type: str + :keyword uri: The target uri of the export pipeline. + When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" + When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". + :paramtype uri: str + :keyword key_vault_uri: They key vault secret uri to obtain the target storage SAS token. + Required. + :paramtype key_vault_uri: str + """ + super().__init__(**kwargs) + self.type = type + self.uri = uri + self.key_vault_uri = key_vault_uri + + +class ExportPolicy(_serialization.Model): + """The export policy for a container registry. + + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPolicyStatus + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs): + """ + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPolicyStatus + """ + super().__init__(**kwargs) + self.status = status + + +class GenerateCredentialsParameters(_serialization.Model): + """The parameters used to generate credentials for a specified token or user of a container registry. + + :ivar token_id: The resource ID of the token for which credentials have to be generated. + :vartype token_id: str + :ivar expiry: The expiry date of the generated credentials after which the credentials become + invalid. + :vartype expiry: ~datetime.datetime + :ivar name: Specifies name of the password which should be regenerated if any -- password1 or + password2. Known values are: "password1" and "password2". + :vartype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPasswordName + """ + + _attribute_map = { + "token_id": {"key": "tokenId", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__( + self, + *, + token_id: Optional[str] = None, + expiry: Optional[datetime.datetime] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, + **kwargs + ): + """ + :keyword token_id: The resource ID of the token for which credentials have to be generated. + :paramtype token_id: str + :keyword expiry: The expiry date of the generated credentials after which the credentials + become invalid. + :paramtype expiry: ~datetime.datetime + :keyword name: Specifies name of the password which should be regenerated if any -- password1 + or password2. Known values are: "password1" and "password2". + :paramtype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPasswordName + """ + super().__init__(**kwargs) + self.token_id = token_id + self.expiry = expiry + self.name = name + + +class GenerateCredentialsResult(_serialization.Model): + """The response from the GenerateCredentials operation. + + :ivar username: The username for a container registry. + :vartype username: str + :ivar passwords: The list of passwords for a container registry. + :vartype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPassword] + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, + } + + def __init__( + self, *, username: Optional[str] = None, passwords: Optional[List["_models.TokenPassword"]] = None, **kwargs + ): + """ + :keyword username: The username for a container registry. + :paramtype username: str + :keyword passwords: The list of passwords for a container registry. + :paramtype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPassword] + """ + super().__init__(**kwargs) + self.username = username + self.passwords = passwords + + +class IdentityProperties(_serialization.Model): + """Managed identity for the resource. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :vartype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity + dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.UserIdentityProperties] + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + tenant_id: Optional[str] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, + **kwargs + ): + """ + :keyword principal_id: The principal ID of resource identity. + :paramtype principal_id: str + :keyword tenant_id: The tenant ID of resource. + :paramtype tenant_id: str + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity + dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.UserIdentityProperties] + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.tenant_id = tenant_id + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ImportImageParameters(_serialization.Model): + """ImportImageParameters. + + All required parameters must be populated in order to send to Azure. + + :ivar source: The source of the image. Required. + :vartype source: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportSource + :ivar target_tags: List of strings of the form repo[:tag]. When tag is omitted the source will + be used (or 'latest' if source tag is also omitted). + :vartype target_tags: list[str] + :ivar untagged_target_repositories: List of strings of repository names to do a manifest only + copy. No tag will be created. + :vartype untagged_target_repositories: list[str] + :ivar mode: When Force, any existing target tags will be overwritten. When NoForce, any + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". + :vartype mode: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportMode + """ + + _validation = { + "source": {"required": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "ImportSource"}, + "target_tags": {"key": "targetTags", "type": "[str]"}, + "untagged_target_repositories": {"key": "untaggedTargetRepositories", "type": "[str]"}, + "mode": {"key": "mode", "type": "str"}, + } + + def __init__( + self, + *, + source: "_models.ImportSource", + target_tags: Optional[List[str]] = None, + untagged_target_repositories: Optional[List[str]] = None, + mode: Union[str, "_models.ImportMode"] = "NoForce", + **kwargs + ): + """ + :keyword source: The source of the image. Required. + :paramtype source: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportSource + :keyword target_tags: List of strings of the form repo[:tag]. When tag is omitted the source + will be used (or 'latest' if source tag is also omitted). + :paramtype target_tags: list[str] + :keyword untagged_target_repositories: List of strings of repository names to do a manifest + only copy. No tag will be created. + :paramtype untagged_target_repositories: list[str] + :keyword mode: When Force, any existing target tags will be overwritten. When NoForce, any + existing target tags will fail the operation before any copying begins. Known values are: + "NoForce" and "Force". + :paramtype mode: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportMode + """ + super().__init__(**kwargs) + self.source = source + self.target_tags = target_tags + self.untagged_target_repositories = untagged_target_repositories + self.mode = mode + + +class ImportPipeline(ProxyResource): + """An object that represents an import pipeline for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar location: The location of the import pipeline. + :vartype location: str + :ivar identity: The identity of the import pipeline. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar source: The source properties of the import pipeline. + :vartype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipelineSourceProperties + :ivar trigger: The properties that describe the trigger of the import pipeline. + :vartype trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineTriggerProperties + :ivar options: The list of all options configured for the pipeline. + :vartype options: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineOptions] + :ivar provisioning_state: The provisioning state of the pipeline at the time the operation was + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "source": {"key": "properties.source", "type": "ImportPipelineSourceProperties"}, + "trigger": {"key": "properties.trigger", "type": "PipelineTriggerProperties"}, + "options": {"key": "properties.options", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + identity: Optional["_models.IdentityProperties"] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + trigger: Optional["_models.PipelineTriggerProperties"] = None, + options: Optional[List[Union[str, "_models.PipelineOptions"]]] = None, + **kwargs + ): + """ + :keyword location: The location of the import pipeline. + :paramtype location: str + :keyword identity: The identity of the import pipeline. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword source: The source properties of the import pipeline. + :paramtype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipelineSourceProperties + :keyword trigger: The properties that describe the trigger of the import pipeline. + :paramtype trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineTriggerProperties + :keyword options: The list of all options configured for the pipeline. + :paramtype options: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineOptions] + """ + super().__init__(**kwargs) + self.location = location + self.identity = identity + self.source = source + self.trigger = trigger + self.options = options + self.provisioning_state = None + + +class ImportPipelineListResult(_serialization.Model): + """The result of a request to list import pipelines for a container registry. + + :ivar value: The list of import pipelines. Since this list may be incomplete, the nextLink + field should be used to request the next list of import pipelines. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :ivar next_link: The URI that can be used to request the next list of pipeline runs. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ImportPipeline]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ImportPipeline"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of import pipelines. Since this list may be incomplete, the nextLink + field should be used to request the next list of import pipelines. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :keyword next_link: The URI that can be used to request the next list of pipeline runs. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ImportPipelineSourceProperties(_serialization.Model): + """The properties of the import pipeline source. + + All required parameters must be populated in order to send to Azure. + + :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" + :vartype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceType + :ivar uri: The source uri of the import pipeline. + When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" + When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". + :vartype uri: str + :ivar key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. + :vartype key_vault_uri: str + """ + + _validation = { + "key_vault_uri": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + } + + def __init__( + self, + *, + key_vault_uri: str, + type: Union[str, "_models.PipelineSourceType"] = "AzureStorageBlobContainer", + uri: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" + :paramtype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceType + :keyword uri: The source uri of the import pipeline. + When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" + When 'AzureStorageBlobContainer': "https://accountName.blob.core.windows.net/containerName". + :paramtype uri: str + :keyword key_vault_uri: They key vault secret uri to obtain the source storage SAS token. + Required. + :paramtype key_vault_uri: str + """ + super().__init__(**kwargs) + self.type = type + self.uri = uri + self.key_vault_uri = key_vault_uri + + +class ImportSource(_serialization.Model): + """ImportSource. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_id: The resource identifier of the source Azure Container Registry. + :vartype resource_id: str + :ivar registry_uri: The address of the source registry (e.g. 'mcr.microsoft.com'). + :vartype registry_uri: str + :ivar credentials: Credentials used when importing from a registry uri. + :vartype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportSourceCredentials + :ivar source_image: Repository name of the source image. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. + :vartype source_image: str + """ + + _validation = { + "source_image": {"required": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "registry_uri": {"key": "registryUri", "type": "str"}, + "credentials": {"key": "credentials", "type": "ImportSourceCredentials"}, + "source_image": {"key": "sourceImage", "type": "str"}, + } + + def __init__( + self, + *, + source_image: str, + resource_id: Optional[str] = None, + registry_uri: Optional[str] = None, + credentials: Optional["_models.ImportSourceCredentials"] = None, + **kwargs + ): + """ + :keyword resource_id: The resource identifier of the source Azure Container Registry. + :paramtype resource_id: str + :keyword registry_uri: The address of the source registry (e.g. 'mcr.microsoft.com'). + :paramtype registry_uri: str + :keyword credentials: Credentials used when importing from a registry uri. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportSourceCredentials + :keyword source_image: Repository name of the source image. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). Required. + :paramtype source_image: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.registry_uri = registry_uri + self.credentials = credentials + self.source_image = source_image + + +class ImportSourceCredentials(_serialization.Model): + """ImportSourceCredentials. + + All required parameters must be populated in order to send to Azure. + + :ivar username: The username to authenticate with the source registry. + :vartype username: str + :ivar password: The password used to authenticate with the source registry. Required. + :vartype password: str + """ + + _validation = { + "password": {"required": True}, + } + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, password: str, username: Optional[str] = None, **kwargs): + """ + :keyword username: The username to authenticate with the source registry. + :paramtype username: str + :keyword password: The password used to authenticate with the source registry. Required. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class InnerErrorDescription(_serialization.Model): + """inner error. + + All required parameters must be populated in order to send to Azure. + + :ivar code: error code. Required. + :vartype code: str + :ivar message: error message. Required. + :vartype message: str + :ivar target: target of the particular error. + :vartype target: str + """ + + _validation = { + "code": {"required": True}, + "message": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__(self, *, code: str, message: str, target: Optional[str] = None, **kwargs): + """ + :keyword code: error code. Required. + :paramtype code: str + :keyword message: error message. Required. + :paramtype message: str + :keyword target: target of the particular error. + :paramtype target: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + + +class IPRule(_serialization.Model): + """IP rule with specific IP or IP range in CIDR format. + + All required parameters must be populated in order to send to Azure. + + :ivar action: The action of IP ACL rule. "Allow" + :vartype action: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Action + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :vartype ip_address_or_range: str + """ + + _validation = { + "ip_address_or_range": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "ip_address_or_range": {"key": "value", "type": "str"}, + } + + def __init__(self, *, ip_address_or_range: str, action: Union[str, "_models.Action"] = "Allow", **kwargs): + """ + :keyword action: The action of IP ACL rule. "Allow" + :paramtype action: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Action + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :paramtype ip_address_or_range: str + """ + super().__init__(**kwargs) + self.action = action + self.ip_address_or_range = ip_address_or_range + + +class KeyVaultProperties(_serialization.Model): + """KeyVaultProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_identifier: Key vault uri to access the encryption key. + :vartype key_identifier: str + :ivar versioned_key_identifier: The fully qualified key identifier that includes the version of + the key that is actually used for encryption. + :vartype versioned_key_identifier: str + :ivar identity: The client id of the identity which will be used to access key vault. + :vartype identity: str + :ivar key_rotation_enabled: Auto key rotation status for a CMK enabled registry. + :vartype key_rotation_enabled: bool + :ivar last_key_rotation_timestamp: Timestamp of the last successful key rotation. + :vartype last_key_rotation_timestamp: ~datetime.datetime + """ + + _validation = { + "versioned_key_identifier": {"readonly": True}, + "key_rotation_enabled": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "versioned_key_identifier": {"key": "versionedKeyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, + "key_rotation_enabled": {"key": "keyRotationEnabled", "type": "bool"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + } + + def __init__(self, *, key_identifier: Optional[str] = None, identity: Optional[str] = None, **kwargs): + """ + :keyword key_identifier: Key vault uri to access the encryption key. + :paramtype key_identifier: str + :keyword identity: The client id of the identity which will be used to access key vault. + :paramtype identity: str + """ + super().__init__(**kwargs) + self.key_identifier = key_identifier + self.versioned_key_identifier = None + self.identity = identity + self.key_rotation_enabled = None + self.last_key_rotation_timestamp = None + + +class LoggingProperties(_serialization.Model): + """The logging properties of the connected registry. + + :ivar log_level: The verbosity of logs persisted on the connected registry. Known values are: + "Debug", "Information", "Warning", "Error", and "None". + :vartype log_level: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LogLevel + :ivar audit_log_status: Indicates whether audit logs are enabled on the connected registry. + Known values are: "Enabled" and "Disabled". + :vartype audit_log_status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuditLogStatus + """ + + _attribute_map = { + "log_level": {"key": "logLevel", "type": "str"}, + "audit_log_status": {"key": "auditLogStatus", "type": "str"}, + } + + def __init__( + self, + *, + log_level: Union[str, "_models.LogLevel"] = "Information", + audit_log_status: Union[str, "_models.AuditLogStatus"] = "Disabled", + **kwargs + ): + """ + :keyword log_level: The verbosity of logs persisted on the connected registry. Known values + are: "Debug", "Information", "Warning", "Error", and "None". + :paramtype log_level: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LogLevel + :keyword audit_log_status: Indicates whether audit logs are enabled on the connected registry. + Known values are: "Enabled" and "Disabled". + :paramtype audit_log_status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AuditLogStatus + """ + super().__init__(**kwargs) + self.log_level = log_level + self.audit_log_status = audit_log_status + + +class LoginServerProperties(_serialization.Model): + """The login server properties of the connected registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar host: The host of the connected registry. Can be FQDN or IP. + :vartype host: str + :ivar tls: The TLS properties of the connected registry login server. + :vartype tls: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TlsProperties + """ + + _validation = { + "host": {"readonly": True}, + "tls": {"readonly": True}, + } + + _attribute_map = { + "host": {"key": "host", "type": "str"}, + "tls": {"key": "tls", "type": "TlsProperties"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.host = None + self.tls = None + + +class NetworkRuleSet(_serialization.Model): + """The network rule set for a container registry. + + All required parameters must be populated in order to send to Azure. + + :ivar default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". + :vartype default_action: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.DefaultAction + :ivar ip_rules: The IP ACL rules. + :vartype ip_rules: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.IPRule] + """ + + _validation = { + "default_action": {"required": True}, + } + + _attribute_map = { + "default_action": {"key": "defaultAction", "type": "str"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + } + + def __init__( + self, + *, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + ip_rules: Optional[List["_models.IPRule"]] = None, + **kwargs + ): + """ + :keyword default_action: The default action of allow or deny when no other rules match. Known + values are: "Allow" and "Deny". + :paramtype default_action: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.DefaultAction + :keyword ip_rules: The IP ACL rules. + :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.IPRule] + """ + super().__init__(**kwargs) + self.default_action = default_action + self.ip_rules = ip_rules + + +class OperationDefinition(_serialization.Model): + """The definition of a container registry operation. + + :ivar origin: The origin information of the container registry operation. + :vartype origin: str + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The display information for the container registry operation. + :vartype display: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDisplayDefinition + :ivar is_data_action: This property indicates if the operation is an action or a data action + ref: + https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations. + :vartype is_data_action: bool + :ivar service_specification: The definition of Azure Monitoring service. + :vartype service_specification: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationServiceSpecificationDefinition + """ + + _attribute_map = { + "origin": {"key": "origin", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplayDefinition"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationServiceSpecificationDefinition", + }, + } + + def __init__( + self, + *, + origin: Optional[str] = None, + name: Optional[str] = None, + display: Optional["_models.OperationDisplayDefinition"] = None, + is_data_action: Optional[bool] = None, + service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, + **kwargs + ): + """ + :keyword origin: The origin information of the container registry operation. + :paramtype origin: str + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The display information for the container registry operation. + :paramtype display: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDisplayDefinition + :keyword is_data_action: This property indicates if the operation is an action or a data action + ref: + https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations. + :paramtype is_data_action: bool + :keyword service_specification: The definition of Azure Monitoring service. + :paramtype service_specification: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationServiceSpecificationDefinition + """ + super().__init__(**kwargs) + self.origin = origin + self.name = name + self.display = display + self.is_data_action = is_data_action + self.service_specification = service_specification + + +class OperationDisplayDefinition(_serialization.Model): + """The display information for a container registry operation. + + :ivar provider: The resource provider name: Microsoft.ContainerRegistry. + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation that users can perform. + :vartype operation: str + :ivar description: The description for the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: The resource provider name: Microsoft.ContainerRegistry. + :paramtype provider: str + :keyword resource: The resource on which the operation is performed. + :paramtype resource: str + :keyword operation: The operation that users can perform. + :paramtype operation: str + :keyword description: The description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """The result of a request to list container registry operations. + + :ivar value: The list of container registry operations. Since this list may be incomplete, the + nextLink field should be used to request the next list of operations. + :vartype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDefinition] + :ivar next_link: The URI that can be used to request the next list of container registry + operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OperationDefinition"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of container registry operations. Since this list may be incomplete, + the nextLink field should be used to request the next list of operations. + :paramtype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDefinition] + :keyword next_link: The URI that can be used to request the next list of container registry + operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationLogSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring log. + + :ivar name: Log name. + :vartype name: str + :ivar display_name: Log display name. + :vartype display_name: str + :ivar blob_duration: Log blob duration. + :vartype blob_duration: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Log name. + :paramtype name: str + :keyword display_name: Log display name. + :paramtype display_name: str + :keyword blob_duration: Log blob duration. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.blob_duration = blob_duration + + +class OperationMetricSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring metric. + + :ivar name: Metric name. + :vartype name: str + :ivar display_name: Metric display name. + :vartype display_name: str + :ivar display_description: Metric description. + :vartype display_description: str + :ivar unit: Metric unit. + :vartype unit: str + :ivar aggregation_type: Metric aggregation type. + :vartype aggregation_type: str + :ivar internal_metric_name: Internal metric name. + :vartype internal_metric_name: str + """ + + _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"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + internal_metric_name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Metric name. + :paramtype name: str + :keyword display_name: Metric display name. + :paramtype display_name: str + :keyword display_description: Metric description. + :paramtype display_description: str + :keyword unit: Metric unit. + :paramtype unit: str + :keyword aggregation_type: Metric aggregation type. + :paramtype aggregation_type: str + :keyword internal_metric_name: Internal metric name. + :paramtype internal_metric_name: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.aggregation_type = aggregation_type + self.internal_metric_name = internal_metric_name + + +class OperationServiceSpecificationDefinition(_serialization.Model): + """The definition of Azure Monitoring list. + + :ivar metric_specifications: A list of Azure Monitoring metrics definition. + :vartype metric_specifications: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationMetricSpecificationDefinition] + :ivar log_specifications: A list of Azure Monitoring log definitions. + :vartype log_specifications: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationLogSpecificationDefinition] + """ + + _attribute_map = { + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationLogSpecificationDefinition]"}, + } + + def __init__( + self, + *, + metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, + log_specifications: Optional[List["_models.OperationLogSpecificationDefinition"]] = None, + **kwargs + ): + """ + :keyword metric_specifications: A list of Azure Monitoring metrics definition. + :paramtype metric_specifications: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationMetricSpecificationDefinition] + :keyword log_specifications: A list of Azure Monitoring log definitions. + :paramtype log_specifications: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationLogSpecificationDefinition] + """ + super().__init__(**kwargs) + self.metric_specifications = metric_specifications + self.log_specifications = log_specifications + + +class PackageType(_serialization.Model): + """The properties of a package type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the package type. + :vartype name: str + :ivar endpoint: The endpoint of the package type. + :vartype endpoint: str + """ + + _validation = { + "endpoint": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The name of the package type. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.endpoint = None + + +class ParentProperties(_serialization.Model): + """The properties of the connected registry parent. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID of the parent to which the connected registry will be associated. + :vartype id: str + :ivar sync_properties: The sync properties of the connected registry with its parent. Required. + :vartype sync_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SyncProperties + """ + + _validation = { + "sync_properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "sync_properties": {"key": "syncProperties", "type": "SyncProperties"}, + } + + def __init__( + self, + *, + sync_properties: "_models.SyncProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin + **kwargs + ): + """ + :keyword id: The resource ID of the parent to which the connected registry will be associated. + :paramtype id: str + :keyword sync_properties: The sync properties of the connected registry with its parent. + Required. + :paramtype sync_properties: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SyncProperties + """ + super().__init__(**kwargs) + self.id = id + self.sync_properties = sync_properties + + +class PipelineRun(ProxyResource): + """An object that represents a pipeline run for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar provisioning_state: The provisioning state of a pipeline run. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar request: The request parameters for a pipeline run. + :vartype request: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunRequest + :ivar response: The response of a pipeline run. + :vartype response: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunResponse + :ivar force_update_tag: How the pipeline run should be forced to recreate even if the pipeline + run configuration has not changed. + :vartype force_update_tag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "response": {"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"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.request", "type": "PipelineRunRequest"}, + "response": {"key": "properties.response", "type": "PipelineRunResponse"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + } + + def __init__( + self, + *, + request: Optional["_models.PipelineRunRequest"] = None, + force_update_tag: Optional[str] = None, + **kwargs + ): + """ + :keyword request: The request parameters for a pipeline run. + :paramtype request: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunRequest + :keyword force_update_tag: How the pipeline run should be forced to recreate even if the + pipeline run configuration has not changed. + :paramtype force_update_tag: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.request = request + self.response = None + self.force_update_tag = force_update_tag + + +class PipelineRunListResult(_serialization.Model): + """The result of a request to list pipeline runs for a container registry. + + :ivar value: The list of pipeline runs. Since this list may be incomplete, the nextLink field + should be used to request the next list of pipeline runs. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :ivar next_link: The URI that can be used to request the next list of pipeline runs. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PipelineRun]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.PipelineRun"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of pipeline runs. Since this list may be incomplete, the nextLink + field should be used to request the next list of pipeline runs. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :keyword next_link: The URI that can be used to request the next list of pipeline runs. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PipelineRunRequest(_serialization.Model): + """The request properties provided for a pipeline run. + + :ivar pipeline_resource_id: The resource ID of the pipeline to run. + :vartype pipeline_resource_id: str + :ivar artifacts: List of source artifacts to be transferred by the pipeline. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + :vartype artifacts: list[str] + :ivar source: The source properties of the pipeline run. + :vartype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunSourceProperties + :ivar target: The target properties of the pipeline run. + :vartype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunTargetProperties + :ivar catalog_digest: The digest of the tar used to transfer the artifacts. + :vartype catalog_digest: str + """ + + _attribute_map = { + "pipeline_resource_id": {"key": "pipelineResourceId", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[str]"}, + "source": {"key": "source", "type": "PipelineRunSourceProperties"}, + "target": {"key": "target", "type": "PipelineRunTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + } + + def __init__( + self, + *, + pipeline_resource_id: Optional[str] = None, + artifacts: Optional[List[str]] = None, + source: Optional["_models.PipelineRunSourceProperties"] = None, + target: Optional["_models.PipelineRunTargetProperties"] = None, + catalog_digest: Optional[str] = None, + **kwargs + ): + """ + :keyword pipeline_resource_id: The resource ID of the pipeline to run. + :paramtype pipeline_resource_id: str + :keyword artifacts: List of source artifacts to be transferred by the pipeline. + Specify an image by repository ('hello-world'). This will use the 'latest' tag. + Specify an image by tag ('hello-world:latest'). + Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). + :paramtype artifacts: list[str] + :keyword source: The source properties of the pipeline run. + :paramtype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunSourceProperties + :keyword target: The target properties of the pipeline run. + :paramtype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunTargetProperties + :keyword catalog_digest: The digest of the tar used to transfer the artifacts. + :paramtype catalog_digest: str + """ + super().__init__(**kwargs) + self.pipeline_resource_id = pipeline_resource_id + self.artifacts = artifacts + self.source = source + self.target = target + self.catalog_digest = catalog_digest + + +class PipelineRunResponse(_serialization.Model): + """The response properties returned for a pipeline run. + + :ivar status: The current status of the pipeline run. + :vartype status: str + :ivar imported_artifacts: The artifacts imported in the pipeline run. + :vartype imported_artifacts: list[str] + :ivar progress: The current progress of the copy operation. + :vartype progress: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProgressProperties + :ivar start_time: The time the pipeline run started. + :vartype start_time: ~datetime.datetime + :ivar finish_time: The time the pipeline run finished. + :vartype finish_time: ~datetime.datetime + :ivar source: The source of the pipeline run. + :vartype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipelineSourceProperties + :ivar target: The target of the pipeline run. + :vartype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipelineTargetProperties + :ivar catalog_digest: The digest of the tar used to transfer the artifacts. + :vartype catalog_digest: str + :ivar trigger: The trigger that caused the pipeline run. + :vartype trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineTriggerDescriptor + :ivar pipeline_run_error_message: The detailed error message for the pipeline run in the case + of failure. + :vartype pipeline_run_error_message: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "imported_artifacts": {"key": "importedArtifacts", "type": "[str]"}, + "progress": {"key": "progress", "type": "ProgressProperties"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "finish_time": {"key": "finishTime", "type": "iso-8601"}, + "source": {"key": "source", "type": "ImportPipelineSourceProperties"}, + "target": {"key": "target", "type": "ExportPipelineTargetProperties"}, + "catalog_digest": {"key": "catalogDigest", "type": "str"}, + "trigger": {"key": "trigger", "type": "PipelineTriggerDescriptor"}, + "pipeline_run_error_message": {"key": "pipelineRunErrorMessage", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[str] = None, + imported_artifacts: Optional[List[str]] = None, + progress: Optional["_models.ProgressProperties"] = None, + start_time: Optional[datetime.datetime] = None, + finish_time: Optional[datetime.datetime] = None, + source: Optional["_models.ImportPipelineSourceProperties"] = None, + target: Optional["_models.ExportPipelineTargetProperties"] = None, + catalog_digest: Optional[str] = None, + trigger: Optional["_models.PipelineTriggerDescriptor"] = None, + pipeline_run_error_message: Optional[str] = None, + **kwargs + ): + """ + :keyword status: The current status of the pipeline run. + :paramtype status: str + :keyword imported_artifacts: The artifacts imported in the pipeline run. + :paramtype imported_artifacts: list[str] + :keyword progress: The current progress of the copy operation. + :paramtype progress: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProgressProperties + :keyword start_time: The time the pipeline run started. + :paramtype start_time: ~datetime.datetime + :keyword finish_time: The time the pipeline run finished. + :paramtype finish_time: ~datetime.datetime + :keyword source: The source of the pipeline run. + :paramtype source: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipelineSourceProperties + :keyword target: The target of the pipeline run. + :paramtype target: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipelineTargetProperties + :keyword catalog_digest: The digest of the tar used to transfer the artifacts. + :paramtype catalog_digest: str + :keyword trigger: The trigger that caused the pipeline run. + :paramtype trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineTriggerDescriptor + :keyword pipeline_run_error_message: The detailed error message for the pipeline run in the + case of failure. + :paramtype pipeline_run_error_message: str + """ + super().__init__(**kwargs) + self.status = status + self.imported_artifacts = imported_artifacts + self.progress = progress + self.start_time = start_time + self.finish_time = finish_time + self.source = source + self.target = target + self.catalog_digest = catalog_digest + self.trigger = trigger + self.pipeline_run_error_message = pipeline_run_error_message + + +class PipelineRunSourceProperties(_serialization.Model): + """PipelineRunSourceProperties. + + :ivar type: The type of the source. "AzureStorageBlob" + :vartype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunSourceType + :ivar name: The name of the source. + :vartype name: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.PipelineRunSourceType"] = "AzureStorageBlob", + name: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The type of the source. "AzureStorageBlob" + :paramtype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunSourceType + :keyword name: The name of the source. + :paramtype name: str + """ + super().__init__(**kwargs) + self.type = type + self.name = name + + +class PipelineRunTargetProperties(_serialization.Model): + """PipelineRunTargetProperties. + + :ivar type: The type of the target. "AzureStorageBlob" + :vartype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunTargetType + :ivar name: The name of the target. + :vartype name: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.PipelineRunTargetType"] = "AzureStorageBlob", + name: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The type of the target. "AzureStorageBlob" + :paramtype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRunTargetType + :keyword name: The name of the target. + :paramtype name: str + """ + super().__init__(**kwargs) + self.type = type + self.name = name + + +class PipelineSourceTriggerDescriptor(_serialization.Model): + """PipelineSourceTriggerDescriptor. + + :ivar timestamp: The timestamp when the source update happened. + :vartype timestamp: ~datetime.datetime + """ + + _attribute_map = { + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): + """ + :keyword timestamp: The timestamp when the source update happened. + :paramtype timestamp: ~datetime.datetime + """ + super().__init__(**kwargs) + self.timestamp = timestamp + + +class PipelineSourceTriggerProperties(_serialization.Model): + """PipelineSourceTriggerProperties. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TriggerStatus + """ + + _validation = { + "status": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs): + """ + :keyword status: The current status of the source trigger. Known values are: "Enabled" and + "Disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TriggerStatus + """ + super().__init__(**kwargs) + self.status = status + + +class PipelineTriggerDescriptor(_serialization.Model): + """PipelineTriggerDescriptor. + + :ivar source_trigger: The source trigger that caused the pipeline run. + :vartype source_trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceTriggerDescriptor + """ + + _attribute_map = { + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, + } + + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs): + """ + :keyword source_trigger: The source trigger that caused the pipeline run. + :paramtype source_trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceTriggerDescriptor + """ + super().__init__(**kwargs) + self.source_trigger = source_trigger + + +class PipelineTriggerProperties(_serialization.Model): + """PipelineTriggerProperties. + + :ivar source_trigger: The source trigger properties of the pipeline. + :vartype source_trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceTriggerProperties + """ + + _attribute_map = { + "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, + } + + def __init__(self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs): + """ + :keyword source_trigger: The source trigger properties of the pipeline. + :paramtype source_trigger: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineSourceTriggerProperties + """ + super().__init__(**kwargs) + self.source_trigger = source_trigger + + +class Policies(_serialization.Model): + """The policies for a container registry. + + :ivar quarantine_policy: The quarantine policy for a container registry. + :vartype quarantine_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.QuarantinePolicy + :ivar trust_policy: The content trust policy for a container registry. + :vartype trust_policy: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TrustPolicy + :ivar retention_policy: The retention policy for a container registry. + :vartype retention_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RetentionPolicy + :ivar export_policy: The export policy for a container registry. + :vartype export_policy: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPolicy + :ivar azure_ad_authentication_as_arm_policy: The policy for using ARM audience token for a + container registry. + :vartype azure_ad_authentication_as_arm_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AzureADAuthenticationAsArmPolicy + :ivar soft_delete_policy: The soft delete policy for a container registry. + :vartype soft_delete_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SoftDeletePolicy + """ + + _attribute_map = { + "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, + "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + "export_policy": {"key": "exportPolicy", "type": "ExportPolicy"}, + "azure_ad_authentication_as_arm_policy": { + "key": "azureADAuthenticationAsArmPolicy", + "type": "AzureADAuthenticationAsArmPolicy", + }, + "soft_delete_policy": {"key": "softDeletePolicy", "type": "SoftDeletePolicy"}, + } + + def __init__( + self, + *, + quarantine_policy: Optional["_models.QuarantinePolicy"] = None, + trust_policy: Optional["_models.TrustPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + export_policy: Optional["_models.ExportPolicy"] = None, + azure_ad_authentication_as_arm_policy: Optional["_models.AzureADAuthenticationAsArmPolicy"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, + **kwargs + ): + """ + :keyword quarantine_policy: The quarantine policy for a container registry. + :paramtype quarantine_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.QuarantinePolicy + :keyword trust_policy: The content trust policy for a container registry. + :paramtype trust_policy: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TrustPolicy + :keyword retention_policy: The retention policy for a container registry. + :paramtype retention_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RetentionPolicy + :keyword export_policy: The export policy for a container registry. + :paramtype export_policy: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPolicy + :keyword azure_ad_authentication_as_arm_policy: The policy for using ARM audience token for a + container registry. + :paramtype azure_ad_authentication_as_arm_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.AzureADAuthenticationAsArmPolicy + :keyword soft_delete_policy: The soft delete policy for a container registry. + :paramtype soft_delete_policy: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SoftDeletePolicy + """ + super().__init__(**kwargs) + self.quarantine_policy = quarantine_policy + self.trust_policy = trust_policy + self.retention_policy = retention_policy + self.export_policy = export_policy + self.azure_ad_authentication_as_arm_policy = azure_ad_authentication_as_arm_policy + self.soft_delete_policy = soft_delete_policy + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + :ivar id: This is private endpoint resource created with Microsoft.Network resource provider. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: This is private endpoint resource created with Microsoft.Network resource + provider. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class PrivateEndpointConnection(ProxyResource): + """An object that represents a private endpoint connection for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar private_endpoint: The resource of private endpoint. + :vartype private_endpoint: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of private endpoint connection resource. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_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"}, + "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__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The resource of private endpoint. + :paramtype private_endpoint: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkServiceConnectionState + """ + 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(_serialization.Model): + """The result of a request to list private endpoint connections for a container registry. + + :ivar value: The list of private endpoint connections. Since this list may be incomplete, the + nextLink field should be used to request the next list of private endpoint connections. + :vartype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :ivar next_link: The URI that can be used to request the next list of private endpoint + connections. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of private endpoint connections. Since this list may be incomplete, + the nextLink field should be used to request the next list of private endpoint connections. + :paramtype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :keyword next_link: The URI that can be used to request the next list of private endpoint + connections. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(_serialization.Model): + """A resource that supports private link capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The resource type is private link resource. + :vartype type: str + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "type": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "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, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword id: The resource ID. + :paramtype id: str + :keyword name: The name of the resource. + :paramtype name: str + :keyword group_id: The private link resource group id. + :paramtype group_id: str + :keyword required_members: The private link resource required member names. + :paramtype required_members: list[str] + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.type = None + self.id = id + self.name = name + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """The result of a request to list private link resources for a container registry. + + :ivar value: The list of private link resources. Since this list may be incomplete, the + nextLink field should be used to request the next list of private link resources. + :vartype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource] + :ivar next_link: The URI that can be used to request the next list of private link resources. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of private link resources. Since this list may be incomplete, the + nextLink field should be used to request the next list of private link resources. + :paramtype value: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource] + :keyword next_link: The URI that can be used to request the next list of private link + resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The state of a private link service connection. + + :ivar status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". + :vartype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectionStatus + :ivar description: The description for connection status. For example if connection is rejected + it can indicate reason for rejection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. Known values are: "None" and "Recreate". + :vartype actions_required: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ActionsRequired + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.ConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, + **kwargs + ): + """ + :keyword status: The private link service connection status. Known values are: "Approved", + "Pending", "Rejected", and "Disconnected". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectionStatus + :keyword description: The description for connection status. For example if connection is + rejected it can indicate reason for rejection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. Known values are: "None" and "Recreate". + :paramtype actions_required: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ActionsRequired + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class ProgressProperties(_serialization.Model): + """ProgressProperties. + + :ivar percentage: The percentage complete of the copy operation. + :vartype percentage: str + """ + + _attribute_map = { + "percentage": {"key": "percentage", "type": "str"}, + } + + def __init__(self, *, percentage: Optional[str] = None, **kwargs): + """ + :keyword percentage: The percentage complete of the copy operation. + :paramtype percentage: str + """ + super().__init__(**kwargs) + self.percentage = percentage + + +class QuarantinePolicy(_serialization.Model): + """The quarantine policy for a container registry. + + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): + """ + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + super().__init__(**kwargs) + self.status = status + + +class RegenerateCredentialParameters(_serialization.Model): + """The parameters used to regenerate the login credential. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PasswordName + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs): + """ + :keyword name: Specifies name of the password which should be regenerated -- password or + password2. Required. Known values are: "password" and "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PasswordName + """ + super().__init__(**kwargs) + self.name = name + + +class Resource(_serialization.Model): + """An Azure resource. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class Registry(Resource): # pylint: disable=too-many-instance-attributes + """An object that represents a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar sku: The SKU of the container registry. Required. + :vartype sku: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Sku + :ivar identity: The identity of the container registry. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar login_server: The URL that can be used to log into the container registry. + :vartype login_server: str + :ivar creation_date: The creation date of the container registry in ISO8601 format. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the container registry at the time the + operation was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar status: The status of the container registry at the time the operation was called. + :vartype status: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Status + :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. + :vartype admin_user_enabled: bool + :ivar network_rule_set: The network rule set for a container registry. + :vartype network_rule_set: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleSet + :ivar policies: The policies for a container registry. + :vartype policies: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Policies + :ivar encryption: The encryption settings of container registry. + :vartype encryption: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionProperty + :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :vartype data_endpoint_enabled: bool + :ivar data_endpoint_host_names: List of host names that will serve data when + dataEndpointEnabled is true. + :vartype data_endpoint_host_names: list[str] + :ivar private_endpoint_connections: List of private endpoint connections for a container + registry. + :vartype private_endpoint_connections: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :ivar public_network_access: Whether or not public network access is allowed for the container + registry. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PublicNetworkAccess + :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network + restricted registry. Known values are: "AzureServices" and "None". + :vartype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleBypassOptions + :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry. + Known values are: "Enabled" and "Disabled". + :vartype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ZoneRedundancy + :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :vartype anonymous_pull_enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "sku": {"required": True}, + "login_server": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "data_endpoint_host_names": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "IdentityProperties"}, + "login_server": {"key": "properties.loginServer", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "data_endpoint_host_names": {"key": "properties.dataEndpointHostNames", "type": "[str]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.IdentityProperties"] = None, + admin_user_enabled: bool = False, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, + data_endpoint_enabled: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + anonymous_pull_enabled: bool = False, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword sku: The SKU of the container registry. Required. + :paramtype sku: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Sku + :keyword identity: The identity of the container registry. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. + :paramtype admin_user_enabled: bool + :keyword network_rule_set: The network rule set for a container registry. + :paramtype network_rule_set: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleSet + :keyword policies: The policies for a container registry. + :paramtype policies: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Policies + :keyword encryption: The encryption settings of container registry. + :paramtype encryption: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionProperty + :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :paramtype data_endpoint_enabled: bool + :keyword public_network_access: Whether or not public network access is allowed for the + container registry. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PublicNetworkAccess + :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a + network restricted registry. Known values are: "AzureServices" and "None". + :paramtype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleBypassOptions + :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container + registry. Known values are: "Enabled" and "Disabled". + :paramtype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ZoneRedundancy + :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :paramtype anonymous_pull_enabled: bool + """ + super().__init__(location=location, tags=tags, **kwargs) + self.sku = sku + self.identity = identity + self.login_server = None + self.creation_date = None + self.provisioning_state = None + self.status = None + self.admin_user_enabled = admin_user_enabled + self.network_rule_set = network_rule_set + self.policies = policies + self.encryption = encryption + self.data_endpoint_enabled = data_endpoint_enabled + self.data_endpoint_host_names = None + self.private_endpoint_connections = None + self.public_network_access = public_network_access + self.network_rule_bypass_options = network_rule_bypass_options + self.zone_redundancy = zone_redundancy + self.anonymous_pull_enabled = anonymous_pull_enabled + + +class RegistryListCredentialsResult(_serialization.Model): + """The response from the ListCredentials operation. + + :ivar username: The username for a container registry. + :vartype username: str + :ivar passwords: The list of passwords for a container registry. + :vartype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryPassword] + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "passwords": {"key": "passwords", "type": "[RegistryPassword]"}, + } + + def __init__( + self, *, username: Optional[str] = None, passwords: Optional[List["_models.RegistryPassword"]] = None, **kwargs + ): + """ + :keyword username: The username for a container registry. + :paramtype username: str + :keyword passwords: The list of passwords for a container registry. + :paramtype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryPassword] + """ + super().__init__(**kwargs) + self.username = username + self.passwords = passwords + + +class RegistryListResult(_serialization.Model): + """The result of a request to list container registries. + + :ivar value: The list of container registries. Since this list may be incomplete, the nextLink + field should be used to request the next list of container registries. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :ivar next_link: The URI that can be used to request the next list of container registries. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Registry]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Registry"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of container registries. Since this list may be incomplete, the + nextLink field should be used to request the next list of container registries. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :keyword next_link: The URI that can be used to request the next list of container registries. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RegistryNameCheckRequest(_serialization.Model): + """A request to check whether a container registry name is available. + + 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 name: The name of the container registry. Required. + :vartype name: str + :ivar type: The resource type of the container registry. This field must be set to + 'Microsoft.ContainerRegistry/registries'. Required. Default value is + "Microsoft.ContainerRegistry/registries". + :vartype type: str + """ + + _validation = { + "name": {"required": True, "max_length": 50, "min_length": 5, "pattern": r"^[a-zA-Z0-9]*$"}, + "type": {"required": True, "constant": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + type = "Microsoft.ContainerRegistry/registries" + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The name of the container registry. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class RegistryNameStatus(_serialization.Model): + """The result of a request to check the availability of a container registry name. + + :ivar name_available: The value that indicates whether the name is available. + :vartype name_available: bool + :ivar reason: If any, the reason that the name is not available. + :vartype reason: str + :ivar message: If any, the error message that provides more detail for the reason that the name + is not available. + :vartype message: str + """ + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: The value that indicates whether the name is available. + :paramtype name_available: bool + :keyword reason: If any, the reason that the name is not available. + :paramtype reason: str + :keyword message: If any, the error message that provides more detail for the reason that the + name is not available. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class RegistryPassword(_serialization.Model): + """The login password for the container registry. + + :ivar name: The password name. Known values are: "password" and "password2". + :vartype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PasswordName + :ivar value: The password value. + :vartype value: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs + ): + """ + :keyword name: The password name. Known values are: "password" and "password2". + :paramtype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PasswordName + :keyword value: The password value. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class RegistryUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters for updating a container registry. + + :ivar identity: The identity of the container registry. + :vartype identity: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :ivar tags: The tags for the container registry. + :vartype tags: dict[str, str] + :ivar sku: The SKU of the container registry. + :vartype sku: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Sku + :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. + :vartype admin_user_enabled: bool + :ivar network_rule_set: The network rule set for a container registry. + :vartype network_rule_set: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleSet + :ivar policies: The policies for a container registry. + :vartype policies: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Policies + :ivar encryption: The encryption settings of container registry. + :vartype encryption: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionProperty + :ivar data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :vartype data_endpoint_enabled: bool + :ivar public_network_access: Whether or not public network access is allowed for the container + registry. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PublicNetworkAccess + :ivar network_rule_bypass_options: Whether to allow trusted Azure services to access a network + restricted registry. Known values are: "AzureServices" and "None". + :vartype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleBypassOptions + :ivar anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :vartype anonymous_pull_enabled: bool + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "IdentityProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkRuleSet", "type": "NetworkRuleSet"}, + "policies": {"key": "properties.policies", "type": "Policies"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionProperty"}, + "data_endpoint_enabled": {"key": "properties.dataEndpointEnabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "network_rule_bypass_options": {"key": "properties.networkRuleBypassOptions", "type": "str"}, + "anonymous_pull_enabled": {"key": "properties.anonymousPullEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + identity: Optional["_models.IdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.Sku"] = None, + admin_user_enabled: Optional[bool] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + policies: Optional["_models.Policies"] = None, + encryption: Optional["_models.EncryptionProperty"] = None, + data_endpoint_enabled: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + network_rule_bypass_options: Optional[Union[str, "_models.NetworkRuleBypassOptions"]] = None, + anonymous_pull_enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword identity: The identity of the container registry. + :paramtype identity: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.IdentityProperties + :keyword tags: The tags for the container registry. + :paramtype tags: dict[str, str] + :keyword sku: The SKU of the container registry. + :paramtype sku: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Sku + :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. + :paramtype admin_user_enabled: bool + :keyword network_rule_set: The network rule set for a container registry. + :paramtype network_rule_set: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleSet + :keyword policies: The policies for a container registry. + :paramtype policies: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Policies + :keyword encryption: The encryption settings of container registry. + :paramtype encryption: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EncryptionProperty + :keyword data_endpoint_enabled: Enable a single data endpoint per region for serving data. + :paramtype data_endpoint_enabled: bool + :keyword public_network_access: Whether or not public network access is allowed for the + container registry. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PublicNetworkAccess + :keyword network_rule_bypass_options: Whether to allow trusted Azure services to access a + network restricted registry. Known values are: "AzureServices" and "None". + :paramtype network_rule_bypass_options: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.NetworkRuleBypassOptions + :keyword anonymous_pull_enabled: Enables registry-wide pull from unauthenticated clients. + :paramtype anonymous_pull_enabled: bool + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + self.sku = sku + self.admin_user_enabled = admin_user_enabled + self.network_rule_set = network_rule_set + self.policies = policies + self.encryption = encryption + self.data_endpoint_enabled = data_endpoint_enabled + self.public_network_access = public_network_access + self.network_rule_bypass_options = network_rule_bypass_options + self.anonymous_pull_enabled = anonymous_pull_enabled + + +class RegistryUsage(_serialization.Model): + """The quota usage for a container registry. + + :ivar name: The name of the usage. + :vartype name: str + :ivar limit: The limit of the usage. + :vartype limit: int + :ivar current_value: The current value of the usage. + :vartype current_value: int + :ivar unit: The unit of measurement. Known values are: "Count" and "Bytes". + :vartype unit: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsageUnit + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "unit": {"key": "unit", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + limit: Optional[int] = None, + current_value: Optional[int] = None, + unit: Optional[Union[str, "_models.RegistryUsageUnit"]] = None, + **kwargs + ): + """ + :keyword name: The name of the usage. + :paramtype name: str + :keyword limit: The limit of the usage. + :paramtype limit: int + :keyword current_value: The current value of the usage. + :paramtype current_value: int + :keyword unit: The unit of measurement. Known values are: "Count" and "Bytes". + :paramtype unit: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsageUnit + """ + super().__init__(**kwargs) + self.name = name + self.limit = limit + self.current_value = current_value + self.unit = unit + + +class RegistryUsageListResult(_serialization.Model): + """The result of a request to get container registry quota usages. + + :ivar value: The list of container registry quota usages. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsage] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RegistryUsage]"}, + } + + def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs): + """ + :keyword value: The list of container registry quota usages. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsage] + """ + super().__init__(**kwargs) + self.value = value + + +class Replication(Resource): + """An object that represents a replication for a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar provisioning_state: The provisioning state of the replication at the time the operation + was called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar status: The status of the replication at the time the operation was called. + :vartype status: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Status + :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :vartype region_endpoint_enabled: bool + :ivar zone_redundancy: Whether or not zone redundancy is enabled for this container registry + replication. Known values are: "Enabled" and "Disabled". + :vartype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ZoneRedundancy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "Status"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + "zone_redundancy": {"key": "properties.zoneRedundancy", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + region_endpoint_enabled: bool = True, + zone_redundancy: Optional[Union[str, "_models.ZoneRedundancy"]] = None, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :paramtype region_endpoint_enabled: bool + :keyword zone_redundancy: Whether or not zone redundancy is enabled for this container registry + replication. Known values are: "Enabled" and "Disabled". + :paramtype zone_redundancy: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ZoneRedundancy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.provisioning_state = None + self.status = None + self.region_endpoint_enabled = region_endpoint_enabled + self.zone_redundancy = zone_redundancy + + +class ReplicationListResult(_serialization.Model): + """The result of a request to list replications for a container registry. + + :ivar value: The list of replications. Since this list may be incomplete, the nextLink field + should be used to request the next list of replications. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :ivar next_link: The URI that can be used to request the next list of replications. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Replication]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Replication"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of replications. Since this list may be incomplete, the nextLink field + should be used to request the next list of replications. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :keyword next_link: The URI that can be used to request the next list of replications. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ReplicationUpdateParameters(_serialization.Model): + """The parameters for updating a replication. + + :ivar tags: The tags for the replication. + :vartype tags: dict[str, str] + :ivar region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :vartype region_endpoint_enabled: bool + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "region_endpoint_enabled": {"key": "properties.regionEndpointEnabled", "type": "bool"}, + } + + def __init__( + self, *, tags: Optional[Dict[str, str]] = None, region_endpoint_enabled: Optional[bool] = None, **kwargs + ): + """ + :keyword tags: The tags for the replication. + :paramtype tags: dict[str, str] + :keyword region_endpoint_enabled: Specifies whether the replication's regional endpoint is + enabled. Requests will not be routed to a replication whose regional endpoint is disabled, + however its data will continue to be synced with other replications. + :paramtype region_endpoint_enabled: bool + """ + super().__init__(**kwargs) + self.tags = tags + self.region_endpoint_enabled = region_endpoint_enabled + + +class Request(_serialization.Model): + """The request that generated the event. + + :ivar id: The ID of the request that initiated the event. + :vartype id: str + :ivar addr: The IP or hostname and possibly port of the client connection that initiated the + event. This is the RemoteAddr from the standard http request. + :vartype addr: str + :ivar host: The externally accessible hostname of the registry instance, as specified by the + http host header on incoming requests. + :vartype host: str + :ivar method: The request method that generated the event. + :vartype method: str + :ivar useragent: The user agent header of the request. + :vartype useragent: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "addr": {"key": "addr", "type": "str"}, + "host": {"key": "host", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "useragent": {"key": "useragent", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + addr: Optional[str] = None, + host: Optional[str] = None, + method: Optional[str] = None, + useragent: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The ID of the request that initiated the event. + :paramtype id: str + :keyword addr: The IP or hostname and possibly port of the client connection that initiated the + event. This is the RemoteAddr from the standard http request. + :paramtype addr: str + :keyword host: The externally accessible hostname of the registry instance, as specified by the + http host header on incoming requests. + :paramtype host: str + :keyword method: The request method that generated the event. + :paramtype method: str + :keyword useragent: The user agent header of the request. + :paramtype useragent: str + """ + super().__init__(**kwargs) + self.id = id + self.addr = addr + self.host = host + self.method = method + self.useragent = useragent + + +class RetentionPolicy(_serialization.Model): + """The retention policy for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar days: The number of days to retain an untagged manifest after which it gets purged. + :vartype days: int + :ivar last_updated_time: The timestamp when the policy was last updated. + :vartype last_updated_time: ~datetime.datetime + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + + _validation = { + "last_updated_time": {"readonly": True}, + } + + _attribute_map = { + "days": {"key": "days", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs): + """ + :keyword days: The number of days to retain an untagged manifest after which it gets purged. + :paramtype days: int + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + super().__init__(**kwargs) + self.days = days + self.last_updated_time = None + self.status = status + + +class ScopeMap(ProxyResource): + """An object that represents a scope map for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar description: The user friendly description of the scope map. + :vartype description: str + :ivar type_properties_type: The type of the scope map. E.g. BuildIn scope map. + :vartype type_properties_type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar actions: The list of scoped permissions for registry artifacts. + E.g. repositories/repository-name/content/read, + repositories/repository-name/metadata/write. + :vartype actions: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "type_properties_type": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): + """ + :keyword description: The user friendly description of the scope map. + :paramtype description: str + :keyword actions: The list of scoped permissions for registry artifacts. + E.g. repositories/repository-name/content/read, + repositories/repository-name/metadata/write. + :paramtype actions: list[str] + """ + super().__init__(**kwargs) + self.description = description + self.type_properties_type = None + self.creation_date = None + self.provisioning_state = None + self.actions = actions + + +class ScopeMapListResult(_serialization.Model): + """The result of a request to list scope maps for a container registry. + + :ivar value: The list of scope maps. Since this list may be incomplete, the nextLink field + should be used to request the next list of scope maps. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :ivar next_link: The URI that can be used to request the next list of scope maps. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ScopeMap]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ScopeMap"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of scope maps. Since this list may be incomplete, the nextLink field + should be used to request the next list of scope maps. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :keyword next_link: The URI that can be used to request the next list of scope maps. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ScopeMapUpdateParameters(_serialization.Model): + """The properties for updating the scope map. + + :ivar description: The user friendly description of the scope map. + :vartype description: str + :ivar actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete. + :vartype actions: list[str] + """ + + _attribute_map = { + "description": {"key": "properties.description", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__(self, *, description: Optional[str] = None, actions: Optional[List[str]] = None, **kwargs): + """ + :keyword description: The user friendly description of the scope map. + :paramtype description: str + :keyword actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete. + :paramtype actions: list[str] + """ + super().__init__(**kwargs) + self.description = description + self.actions = actions + + +class Sku(_serialization.Model): + """The SKU of a container registry. + + 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 name: The SKU name of the container registry. Required for registry creation. Required. + Known values are: "Classic", "Basic", "Standard", and "Premium". + :vartype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SkuName + :ivar tier: The SKU tier based on the SKU name. Known values are: "Classic", "Basic", + "Standard", and "Premium". + :vartype tier: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): + """ + :keyword name: The SKU name of the container registry. Required for registry creation. + Required. Known values are: "Classic", "Basic", "Standard", and "Premium". + :paramtype name: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class SoftDeletePolicy(_serialization.Model): + """The soft delete policy for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar retention_days: The number of days after which a soft-deleted item is permanently + deleted. + :vartype retention_days: int + :ivar last_updated_time: The timestamp when the policy was last updated. + :vartype last_updated_time: ~datetime.datetime + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + + _validation = { + "last_updated_time": {"readonly": True}, + } + + _attribute_map = { + "retention_days": {"key": "retentionDays", "type": "int"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, *, retention_days: int = 7, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs + ): + """ + :keyword retention_days: The number of days after which a soft-deleted item is permanently + deleted. + :paramtype retention_days: int + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + super().__init__(**kwargs) + self.retention_days = retention_days + self.last_updated_time = None + self.status = status + + +class Source(_serialization.Model): + """The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + + :ivar addr: The IP or hostname and the port of the registry node that generated the event. + Generally, this will be resolved by os.Hostname() along with the running port. + :vartype addr: str + :ivar instance_id: The running instance of an application. Changes after each restart. + :vartype instance_id: str + """ + + _attribute_map = { + "addr": {"key": "addr", "type": "str"}, + "instance_id": {"key": "instanceID", "type": "str"}, + } + + def __init__(self, *, addr: Optional[str] = None, instance_id: Optional[str] = None, **kwargs): + """ + :keyword addr: The IP or hostname and the port of the registry node that generated the event. + Generally, this will be resolved by os.Hostname() along with the running port. + :paramtype addr: str + :keyword instance_id: The running instance of an application. Changes after each restart. + :paramtype instance_id: str + """ + super().__init__(**kwargs) + self.addr = addr + self.instance_id = instance_id + + +class Status(_serialization.Model): + """The status of an Azure resource at the time the operation was called. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_status: The short label for the status. + :vartype display_status: str + :ivar message: The detailed message for the status, including alerts and error messages. + :vartype message: str + :ivar timestamp: The timestamp when the status was changed to the current value. + :vartype timestamp: ~datetime.datetime + """ + + _validation = { + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "timestamp": {"readonly": True}, + } + + _attribute_map = { + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.display_status = None + self.message = None + self.timestamp = None + + +class StatusDetailProperties(_serialization.Model): + """The status detail properties of the connected registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The component of the connected registry corresponding to the status. + :vartype type: str + :ivar code: The code of the status. + :vartype code: str + :ivar description: The description of the status. + :vartype description: str + :ivar timestamp: The timestamp of the status. + :vartype timestamp: ~datetime.datetime + :ivar correlation_id: The correlation ID of the status. + :vartype correlation_id: str + """ + + _validation = { + "type": {"readonly": True}, + "code": {"readonly": True}, + "description": {"readonly": True}, + "timestamp": {"readonly": True}, + "correlation_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.code = None + self.description = None + self.timestamp = None + self.correlation_id = None + + +class StorageAccountProperties(_serialization.Model): + """The properties of a storage account for a container registry. Only applicable to Classic SKU. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID of the storage account. Required. + :vartype id: str + """ + + _validation = { + "id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The resource ID of the storage account. Required. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class SyncProperties(_serialization.Model): + """The sync properties of the connected registry with its parent. + + 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 token_id: The resource ID of the ACR token used to authenticate the connected registry to + its parent during sync. Required. + :vartype token_id: str + :ivar schedule: The cron expression indicating the schedule that the connected registry will + sync with its parent. + :vartype schedule: str + :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. + Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :vartype sync_window: ~datetime.timedelta + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. + :vartype message_ttl: ~datetime.timedelta + :ivar last_sync_time: The last time a sync occurred between the connected registry and its + parent. + :vartype last_sync_time: ~datetime.datetime + :ivar gateway_endpoint: The gateway endpoint used by the connected registry to communicate with + its parent. + :vartype gateway_endpoint: str + """ + + _validation = { + "token_id": {"required": True}, + "message_ttl": {"required": True}, + "last_sync_time": {"readonly": True}, + "gateway_endpoint": {"readonly": True}, + } + + _attribute_map = { + "token_id": {"key": "tokenId", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "gateway_endpoint": {"key": "gatewayEndpoint", "type": "str"}, + } + + def __init__( + self, + *, + token_id: str, + message_ttl: datetime.timedelta, + schedule: Optional[str] = None, + sync_window: Optional[datetime.timedelta] = None, + **kwargs + ): + """ + :keyword token_id: The resource ID of the ACR token used to authenticate the connected registry + to its parent during sync. Required. + :paramtype token_id: str + :keyword schedule: The cron expression indicating the schedule that the connected registry will + sync with its parent. + :paramtype schedule: str + :keyword sync_window: The time window during which sync is enabled for each schedule + occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :paramtype sync_window: ~datetime.timedelta + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + Required. + :paramtype message_ttl: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.token_id = token_id + self.schedule = schedule + self.sync_window = sync_window + self.message_ttl = message_ttl + self.last_sync_time = None + self.gateway_endpoint = None + + +class SyncUpdateProperties(_serialization.Model): + """The parameters for updating the sync properties of the connected registry with its parent. + + :ivar schedule: The cron expression indicating the schedule that the connected registry will + sync with its parent. + :vartype schedule: str + :ivar sync_window: The time window during which sync is enabled for each schedule occurrence. + Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :vartype sync_window: ~datetime.timedelta + :ivar message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :vartype message_ttl: ~datetime.timedelta + """ + + _attribute_map = { + "schedule": {"key": "schedule", "type": "str"}, + "sync_window": {"key": "syncWindow", "type": "duration"}, + "message_ttl": {"key": "messageTtl", "type": "duration"}, + } + + def __init__( + self, + *, + schedule: Optional[str] = None, + sync_window: Optional[datetime.timedelta] = None, + message_ttl: Optional[datetime.timedelta] = None, + **kwargs + ): + """ + :keyword schedule: The cron expression indicating the schedule that the connected registry will + sync with its parent. + :paramtype schedule: str + :keyword sync_window: The time window during which sync is enabled for each schedule + occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :paramtype sync_window: ~datetime.timedelta + :keyword message_ttl: The period of time for which a message is available to sync before it is + expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + :paramtype message_ttl: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.schedule = schedule + self.sync_window = sync_window + self.message_ttl = message_ttl + + +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", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.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", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LastModifiedByType + :ivar last_modified_at: The timestamp of resource 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"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.LastModifiedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :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", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.LastModifiedByType + :keyword last_modified_at: The timestamp of resource modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Target(_serialization.Model): + """The target of the event. + + :ivar media_type: The MIME type of the referenced object. + :vartype media_type: str + :ivar size: The number of bytes of the content. Same as Length field. + :vartype size: int + :ivar digest: The digest of the content, as defined by the Registry V2 HTTP API Specification. + :vartype digest: str + :ivar length: The number of bytes of the content. Same as Size field. + :vartype length: int + :ivar repository: The repository name. + :vartype repository: str + :ivar url: The direct URL to the content. + :vartype url: str + :ivar tag: The tag name. + :vartype tag: str + :ivar name: The name of the artifact. + :vartype name: str + :ivar version: The version of the artifact. + :vartype version: str + """ + + _attribute_map = { + "media_type": {"key": "mediaType", "type": "str"}, + "size": {"key": "size", "type": "int"}, + "digest": {"key": "digest", "type": "str"}, + "length": {"key": "length", "type": "int"}, + "repository": {"key": "repository", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + media_type: Optional[str] = None, + size: Optional[int] = None, + digest: Optional[str] = None, + length: Optional[int] = None, + repository: Optional[str] = None, + url: Optional[str] = None, + tag: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword media_type: The MIME type of the referenced object. + :paramtype media_type: str + :keyword size: The number of bytes of the content. Same as Length field. + :paramtype size: int + :keyword digest: The digest of the content, as defined by the Registry V2 HTTP API + Specification. + :paramtype digest: str + :keyword length: The number of bytes of the content. Same as Size field. + :paramtype length: int + :keyword repository: The repository name. + :paramtype repository: str + :keyword url: The direct URL to the content. + :paramtype url: str + :keyword tag: The tag name. + :paramtype tag: str + :keyword name: The name of the artifact. + :paramtype name: str + :keyword version: The version of the artifact. + :paramtype version: str + """ + super().__init__(**kwargs) + self.media_type = media_type + self.size = size + self.digest = digest + self.length = length + self.repository = repository + self.url = url + self.tag = tag + self.name = name + self.version = version + + +class TlsCertificateProperties(_serialization.Model): + """The TLS certificate properties of the connected registry login server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of certificate location. "LocalDirectory" + :vartype type: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CertificateType + :ivar location: Indicates the location of the certificates. + :vartype location: str + """ + + _validation = { + "type": {"readonly": True}, + "location": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.location = None + + +class TlsProperties(_serialization.Model): + """The TLS properties of the connected registry login server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: Indicates whether HTTPS is enabled for the login server. Known values are: + "Enabled" and "Disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TlsStatus + :ivar certificate: The certificate used to configure HTTPS for the login server. + :vartype certificate: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TlsCertificateProperties + """ + + _validation = { + "status": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "certificate": {"key": "certificate", "type": "TlsCertificateProperties"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.status = None + self.certificate = None + + +class Token(ProxyResource): + """An object that represents a token for a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar creation_date: The creation date of scope map. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + :ivar scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :vartype scope_map_id: str + :ivar credentials: The credentials that can be used for authenticating the token. + :vartype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCredentialsProperties + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_date": {"readonly": True}, + "provisioning_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"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + "status": {"key": "properties.status", "type": "str"}, + } + + def __init__( + self, + *, + scope_map_id: Optional[str] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + **kwargs + ): + """ + :keyword scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :paramtype scope_map_id: str + :keyword credentials: The credentials that can be used for authenticating the token. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCredentialsProperties + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenStatus + """ + super().__init__(**kwargs) + self.creation_date = None + self.provisioning_state = None + self.scope_map_id = scope_map_id + self.credentials = credentials + self.status = status + + +class TokenCertificate(_serialization.Model): + """The properties of a certificate used for authenticating a token. + + :ivar name: Known values are: "certificate1" and "certificate2". + :vartype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCertificateName + :ivar expiry: The expiry datetime of the certificate. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The thumbprint of the certificate. + :vartype thumbprint: str + :ivar encoded_pem_certificate: Base 64 encoded string of the public certificate1 in PEM format + that will be used for authenticating the token. + :vartype encoded_pem_certificate: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "encoded_pem_certificate": {"key": "encodedPemCertificate", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "_models.TokenCertificateName"]] = None, + expiry: Optional[datetime.datetime] = None, + thumbprint: Optional[str] = None, + encoded_pem_certificate: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Known values are: "certificate1" and "certificate2". + :paramtype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCertificateName + :keyword expiry: The expiry datetime of the certificate. + :paramtype expiry: ~datetime.datetime + :keyword thumbprint: The thumbprint of the certificate. + :paramtype thumbprint: str + :keyword encoded_pem_certificate: Base 64 encoded string of the public certificate1 in PEM + format that will be used for authenticating the token. + :paramtype encoded_pem_certificate: str + """ + super().__init__(**kwargs) + self.name = name + self.expiry = expiry + self.thumbprint = thumbprint + self.encoded_pem_certificate = encoded_pem_certificate + + +class TokenCredentialsProperties(_serialization.Model): + """The properties of the credentials that can be used for authenticating the token. + + :ivar certificates: + :vartype certificates: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCertificate] + :ivar passwords: + :vartype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPassword] + """ + + _attribute_map = { + "certificates": {"key": "certificates", "type": "[TokenCertificate]"}, + "passwords": {"key": "passwords", "type": "[TokenPassword]"}, + } + + def __init__( + self, + *, + certificates: Optional[List["_models.TokenCertificate"]] = None, + passwords: Optional[List["_models.TokenPassword"]] = None, + **kwargs + ): + """ + :keyword certificates: + :paramtype certificates: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCertificate] + :keyword passwords: + :paramtype passwords: + list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPassword] + """ + super().__init__(**kwargs) + self.certificates = certificates + self.passwords = passwords + + +class TokenListResult(_serialization.Model): + """The result of a request to list tokens for a container registry. + + :ivar value: The list of tokens. Since this list may be incomplete, the nextLink field should + be used to request the next list of tokens. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :ivar next_link: The URI that can be used to request the next list of tokens. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Token]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Token"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of tokens. Since this list may be incomplete, the nextLink field + should be used to request the next list of tokens. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :keyword next_link: The URI that can be used to request the next list of tokens. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class TokenPassword(_serialization.Model): + """The password that will be used for authenticating the token of a container registry. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar creation_time: The creation datetime of the password. + :vartype creation_time: ~datetime.datetime + :ivar expiry: The expiry datetime of the password. + :vartype expiry: ~datetime.datetime + :ivar name: The password name "password1" or "password2". Known values are: "password1" and + "password2". + :vartype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPasswordName + :ivar value: The password value. + :vartype value: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + creation_time: Optional[datetime.datetime] = None, + expiry: Optional[datetime.datetime] = None, + name: Optional[Union[str, "_models.TokenPasswordName"]] = None, + **kwargs + ): + """ + :keyword creation_time: The creation datetime of the password. + :paramtype creation_time: ~datetime.datetime + :keyword expiry: The expiry datetime of the password. + :paramtype expiry: ~datetime.datetime + :keyword name: The password name "password1" or "password2". Known values are: "password1" and + "password2". + :paramtype name: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenPasswordName + """ + super().__init__(**kwargs) + self.creation_time = creation_time + self.expiry = expiry + self.name = name + self.value = None + + +class TokenUpdateParameters(_serialization.Model): + """The parameters for updating a token. + + :ivar scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :vartype scope_map_id: str + :ivar status: The status of the token example enabled or disabled. Known values are: "enabled" + and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenStatus + :ivar credentials: The credentials that can be used for authenticating the token. + :vartype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCredentialsProperties + """ + + _attribute_map = { + "scope_map_id": {"key": "properties.scopeMapId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "credentials": {"key": "properties.credentials", "type": "TokenCredentialsProperties"}, + } + + def __init__( + self, + *, + scope_map_id: Optional[str] = None, + status: Optional[Union[str, "_models.TokenStatus"]] = None, + credentials: Optional["_models.TokenCredentialsProperties"] = None, + **kwargs + ): + """ + :keyword scope_map_id: The resource ID of the scope map to which the token will be associated + with. + :paramtype scope_map_id: str + :keyword status: The status of the token example enabled or disabled. Known values are: + "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenStatus + :keyword credentials: The credentials that can be used for authenticating the token. + :paramtype credentials: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenCredentialsProperties + """ + super().__init__(**kwargs) + self.scope_map_id = scope_map_id + self.status = status + self.credentials = credentials + + +class TrustPolicy(_serialization.Model): + """The content trust policy for a container registry. + + :ivar type: The type of trust policy. "Notary" + :vartype type: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TrustPolicyType + :ivar status: The value that indicates whether the policy is enabled or not. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.TrustPolicyType"] = "Notary", + status: Optional[Union[str, "_models.PolicyStatus"]] = None, + **kwargs + ): + """ + :keyword type: The type of trust policy. "Notary" + :paramtype type: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TrustPolicyType + :keyword status: The value that indicates whether the policy is enabled or not. Known values + are: "enabled" and "disabled". + :paramtype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PolicyStatus + """ + super().__init__(**kwargs) + self.type = type + self.status = status + + +class UserIdentityProperties(_serialization.Model): + """UserIdentityProperties. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): + """ + :keyword principal_id: The principal id of user assigned identity. + :paramtype principal_id: str + :keyword client_id: The client id of user assigned identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.client_id = client_id + + +class Webhook(Resource): + """An object that represents a webhook for a container registry. + + 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: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar location: The location of the resource. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.SystemData + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + :ivar provisioning_state: The provisioning state of the webhook at the time the operation was + called. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword location: The location of the resource. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.status = status + self.scope = scope + self.actions = actions + self.provisioning_state = None + + +class WebhookCreateParameters(_serialization.Model): + """The parameters for creating a webhook. + + All required parameters must be populated in order to send to Azure. + + :ivar tags: The tags for the webhook. + :vartype tags: dict[str, str] + :ivar location: The location of the webhook. This cannot be changed after the resource is + created. Required. + :vartype location: str + :ivar service_uri: The service URI for the webhook to post notifications. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + """ + + _validation = { + "location": {"required": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + service_uri: Optional[str] = None, + custom_headers: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword tags: The tags for the webhook. + :paramtype tags: dict[str, str] + :keyword location: The location of the webhook. This cannot be changed after the resource is + created. Required. + :paramtype location: str + :keyword service_uri: The service URI for the webhook to post notifications. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + self.service_uri = service_uri + self.custom_headers = custom_headers + self.status = status + self.scope = scope + self.actions = actions + + +class WebhookListResult(_serialization.Model): + """The result of a request to list webhooks for a container registry. + + :ivar value: The list of webhooks. Since this list may be incomplete, the nextLink field should + be used to request the next list of webhooks. + :vartype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :ivar next_link: The URI that can be used to request the next list of webhooks. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Webhook]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of webhooks. Since this list may be incomplete, the nextLink field + should be used to request the next list of webhooks. + :paramtype value: list[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :keyword next_link: The URI that can be used to request the next list of webhooks. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class WebhookUpdateParameters(_serialization.Model): + """The parameters for updating a webhook. + + :ivar tags: The tags for the webhook. + :vartype tags: dict[str, str] + :ivar service_uri: The service URI for the webhook to post notifications. + :vartype service_uri: str + :ivar custom_headers: Custom headers that will be added to the webhook notifications. + :vartype custom_headers: dict[str, str] + :ivar status: The status of the webhook at the time the operation was called. Known values are: + "enabled" and "disabled". + :vartype status: str or ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :ivar scope: The scope of repositories where the event can be triggered. For example, 'foo:*' + means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. + 'foo' is equivalent to 'foo:latest'. Empty means all events. + :vartype scope: str + :ivar actions: The list of actions that trigger the webhook to post notifications. + :vartype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "service_uri": {"key": "properties.serviceUri", "type": "str"}, + "custom_headers": {"key": "properties.customHeaders", "type": "{str}"}, + "status": {"key": "properties.status", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "actions": {"key": "properties.actions", "type": "[str]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + service_uri: Optional[str] = None, + custom_headers: Optional[Dict[str, str]] = None, + status: Optional[Union[str, "_models.WebhookStatus"]] = None, + scope: Optional[str] = None, + actions: Optional[List[Union[str, "_models.WebhookAction"]]] = None, + **kwargs + ): + """ + :keyword tags: The tags for the webhook. + :paramtype tags: dict[str, str] + :keyword service_uri: The service URI for the webhook to post notifications. + :paramtype service_uri: str + :keyword custom_headers: Custom headers that will be added to the webhook notifications. + :paramtype custom_headers: dict[str, str] + :keyword status: The status of the webhook at the time the operation was called. Known values + are: "enabled" and "disabled". + :paramtype status: str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookStatus + :keyword scope: The scope of repositories where the event can be triggered. For example, + 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' + only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + :paramtype scope: str + :keyword actions: The list of actions that trigger the webhook to post notifications. + :paramtype actions: list[str or + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookAction] + """ + super().__init__(**kwargs) + self.tags = tags + self.service_uri = service_uri + self.custom_headers = custom_headers + self.status = status + self.scope = scope + self.actions = actions diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/__init__.py new file mode 100644 index 000000000000..da883493d287 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/__init__.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._cache_rules_operations import CacheRulesOperations +from ._connected_registries_operations import ConnectedRegistriesOperations +from ._credential_sets_operations import CredentialSetsOperations +from ._export_pipelines_operations import ExportPipelinesOperations +from ._registries_operations import RegistriesOperations +from ._import_pipelines_operations import ImportPipelinesOperations +from ._operations import Operations +from ._pipeline_runs_operations import PipelineRunsOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._replications_operations import ReplicationsOperations +from ._scope_maps_operations import ScopeMapsOperations +from ._tokens_operations import TokensOperations +from ._webhooks_operations import WebhooksOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "CacheRulesOperations", + "ConnectedRegistriesOperations", + "CredentialSetsOperations", + "ExportPipelinesOperations", + "RegistriesOperations", + "ImportPipelinesOperations", + "Operations", + "PipelineRunsOperations", + "PrivateEndpointConnectionsOperations", + "ReplicationsOperations", + "ScopeMapsOperations", + "TokensOperations", + "WebhooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_cache_rules_operations.py new file mode 100644 index 000000000000..6e9632e5d0b0 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_cache_rules_operations.py @@ -0,0 +1,1054 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, cache_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "cacheRuleName": _SERIALIZER.url( + "cache_rule_name", cache_rule_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, cache_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "cacheRuleName": _SERIALIZER.url( + "cache_rule_name", cache_rule_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, cache_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "cacheRuleName": _SERIALIZER.url( + "cache_rule_name", cache_rule_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, cache_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "cacheRuleName": _SERIALIZER.url( + "cache_rule_name", cache_rule_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class CacheRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`cache_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.CacheRule"]: + """Lists all cache rule resources for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CacheRule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CacheRulesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> _models.CacheRule: + """Gets the properties of the specified cache rule resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CacheRule or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: Union[_models.CacheRule, IO], + **kwargs: Any + ) -> _models.CacheRule: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cache_rule_create_parameters, (IO, bytes)): + _content = cache_rule_create_parameters + else: + _json = self._serialize.body(cache_rule_create_parameters, "CacheRule") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CacheRule", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: _models.CacheRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Required. + :type cache_rule_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule + :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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Required. + :type cache_rule_create_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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_create_parameters: Union[_models.CacheRule, IO], + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Creates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_create_parameters: The parameters for creating a cache rule. Is either a + model type or a IO type. Required. + :type cache_rule_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule 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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + cache_rule_create_parameters=cache_rule_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CacheRule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a cache rule resource from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO], + **kwargs: Any + ) -> _models.CacheRule: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cache_rule_update_parameters, (IO, bytes)): + _content = cache_rule_update_parameters + else: + _json = self._serialize.body(cache_rule_update_parameters, "CacheRuleUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CacheRule", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CacheRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: _models.CacheRuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Required. + :type cache_rule_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRuleUpdateParameters + :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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Required. + :type cache_rule_update_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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + cache_rule_name: str, + cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.CacheRule]: + """Updates a cache rule for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param cache_rule_name: The name of the cache rule. Required. + :type cache_rule_name: str + :param cache_rule_update_parameters: The parameters for updating a cache rule. Is either a + model type or a IO type. Required. + :type cache_rule_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRuleUpdateParameters 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 CacheRule or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CacheRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + cache_rule_name=cache_rule_name, + cache_rule_update_parameters=cache_rule_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CacheRule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/cacheRules/{cacheRuleName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_connected_registries_operations.py new file mode 100644 index 000000000000..afea47349321 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_connected_registries_operations.py @@ -0,0 +1,1267 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "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, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deactivate_request( + resource_group_name: str, registry_name: str, connected_registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "connectedRegistryName": _SERIALIZER.url( + "connected_registry_name", + connected_registry_name, + "str", + max_length=50, + min_length=5, + pattern=r"^[a-zA-Z0-9]*$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedRegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`connected_registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ConnectedRegistry"]: + """Lists all connected registries for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param filter: An OData filter expression that describes a subset of connectedRegistries to + return. The parameters that can be filtered are parent.id (the resource id of the + connectedRegistry parent), mode, and connectionState. The supported operator is eq. Default + value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedRegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> _models.ConnectedRegistry: + """Gets the properties of the connected registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedRegistry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], + **kwargs: Any + ) -> _models.ConnectedRegistry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_create_parameters, (IO, bytes)): + _content = connected_registry_create_parameters + else: + _json = self._serialize.body(connected_registry_create_parameters, "ConnectedRegistry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: _models.ConnectedRegistry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Required. + :type connected_registry_create_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO], + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Creates a connected registry for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_create_parameters: The parameters for creating a connectedRegistry. + Is either a model type or a IO type. Required. + :type connected_registry_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry 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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + connected_registry_create_parameters=connected_registry_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a connected registry from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.ConnectedRegistry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connected_registry_update_parameters, (IO, bytes)): + _content = connected_registry_update_parameters + else: + _json = self._serialize.body(connected_registry_update_parameters, "ConnectedRegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: _models.ConnectedRegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryUpdateParameters + :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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Required. + :type connected_registry_update_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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + connected_registry_name: str, + connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ConnectedRegistry]: + """Updates a connected registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :param connected_registry_update_parameters: The parameters for updating a connectedRegistry. + Is either a model type or a IO type. Required. + :type connected_registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistryUpdateParameters 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 ConnectedRegistry or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ConnectedRegistry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectedRegistry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + connected_registry_update_parameters=connected_registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedRegistry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + } + + def _deactivate_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_deactivate_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._deactivate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _deactivate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } + + @distributed_trace + def begin_deactivate( + self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deactivates the connected registry instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param connected_registry_name: The name of the connected registry. Required. + :type connected_registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._deactivate_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + connected_registry_name=connected_registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_deactivate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_credential_sets_operations.py new file mode 100644 index 000000000000..bbe6fe958953 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_credential_sets_operations.py @@ -0,0 +1,1064 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, credential_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "credentialSetName": _SERIALIZER.url( + "credential_set_name", credential_set_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, credential_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "credentialSetName": _SERIALIZER.url( + "credential_set_name", credential_set_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, credential_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "credentialSetName": _SERIALIZER.url( + "credential_set_name", credential_set_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, credential_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "credentialSetName": _SERIALIZER.url( + "credential_set_name", credential_set_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class CredentialSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`credential_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.CredentialSet"]: + """Lists all credential set resources for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CredentialSet or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CredentialSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> _models.CredentialSet: + """Gets the properties of the specified credential set resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CredentialSet or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: Union[_models.CredentialSet, IO], + **kwargs: Any + ) -> _models.CredentialSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(credential_set_create_parameters, (IO, bytes)): + _content = credential_set_create_parameters + else: + _json = self._serialize.body(credential_set_create_parameters, "CredentialSet") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: _models.CredentialSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. + Required. + :type credential_set_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet + :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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. + Required. + :type credential_set_create_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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_create_parameters: Union[_models.CredentialSet, IO], + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Creates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_create_parameters: The parameters for creating a credential set. Is + either a model type or a IO type. Required. + :type credential_set_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet 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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + credential_set_create_parameters=credential_set_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CredentialSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a credential set from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO], + **kwargs: Any + ) -> _models.CredentialSet: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(credential_set_update_parameters, (IO, bytes)): + _content = credential_set_update_parameters + else: + _json = self._serialize.body(credential_set_update_parameters, "CredentialSetUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("CredentialSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: _models.CredentialSetUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. + Required. + :type credential_set_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSetUpdateParameters + :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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. + Required. + :type credential_set_update_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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + credential_set_name: str, + credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.CredentialSet]: + """Updates a credential set for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param credential_set_name: The name of the credential set. Required. + :type credential_set_name: str + :param credential_set_update_parameters: The parameters for updating a credential set. Is + either a model type or a IO type. Required. + :type credential_set_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSetUpdateParameters 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 CredentialSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.CredentialSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CredentialSet] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + credential_set_name=credential_set_name, + credential_set_update_parameters=credential_set_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CredentialSet", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/credentialSets/{credentialSetName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_export_pipelines_operations.py new file mode 100644 index 000000000000..f6c89e07977d --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_export_pipelines_operations.py @@ -0,0 +1,766 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, export_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "exportPipelineName": _SERIALIZER.url( + "export_pipeline_name", export_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`export_pipelines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ExportPipeline"]: + """Lists all export pipelines for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExportPipeline or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExportPipelineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> _models.ExportPipeline: + """Gets the properties of the export pipeline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExportPipeline or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> _models.ExportPipeline: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_pipeline_create_parameters, (IO, bytes)): + _content = export_pipeline_create_parameters + else: + _json = self._serialize.body(export_pipeline_create_parameters, "ExportPipeline") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ExportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: _models.ExportPipeline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline + :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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. + Required. + :type export_pipeline_create_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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + export_pipeline_name: str, + export_pipeline_create_parameters: Union[_models.ExportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ExportPipeline]: + """Creates an export pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :param export_pipeline_create_parameters: The parameters for creating an export pipeline. Is + either a model type or a IO type. Required. + :type export_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline 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 ExportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ExportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + export_pipeline_create_parameters=export_pipeline_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ExportPipeline", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an export pipeline from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param export_pipeline_name: The name of the export pipeline. Required. + :type export_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + export_pipeline_name=export_pipeline_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_import_pipelines_operations.py new file mode 100644 index 000000000000..b03124eb8a79 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_import_pipelines_operations.py @@ -0,0 +1,766 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, import_pipeline_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "importPipelineName": _SERIALIZER.url( + "import_pipeline_name", import_pipeline_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ImportPipelinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`import_pipelines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ImportPipeline"]: + """Lists all import pipelines for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImportPipeline or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ImportPipelineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> _models.ImportPipeline: + """Gets the properties of the import pipeline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImportPipeline or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> _models.ImportPipeline: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_pipeline_create_parameters, (IO, bytes)): + _content = import_pipeline_create_parameters + else: + _json = self._serialize.body(import_pipeline_create_parameters, "ImportPipeline") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ImportPipeline", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: _models.ImportPipeline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline + :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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. + Required. + :type import_pipeline_create_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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + import_pipeline_name: str, + import_pipeline_create_parameters: Union[_models.ImportPipeline, IO], + **kwargs: Any + ) -> LROPoller[_models.ImportPipeline]: + """Creates an import pipeline for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :param import_pipeline_create_parameters: The parameters for creating an import pipeline. Is + either a model type or a IO type. Required. + :type import_pipeline_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline 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 ImportPipeline or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportPipeline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImportPipeline] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + import_pipeline_create_parameters=import_pipeline_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ImportPipeline", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an import pipeline from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param import_pipeline_name: The name of the import pipeline. Required. + :type import_pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + import_pipeline_name=import_pipeline_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_operations.py new file mode 100644 index 000000000000..6885d8792711 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_operations.py @@ -0,0 +1,163 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerRegistry/operations") + + # 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) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: + """Lists all of the available Azure Container Registry REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.OperationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ContainerRegistry/operations"} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_pipeline_runs_operations.py new file mode 100644 index 000000000000..7353b04d2897 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_pipeline_runs_operations.py @@ -0,0 +1,764 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, pipeline_run_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "pipelineRunName": _SERIALIZER.url( + "pipeline_run_name", pipeline_run_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PipelineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`pipeline_runs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.PipelineRun"]: + """Lists all the pipeline runs for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PipelineRun or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PipelineRunListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> _models.PipelineRun: + """Gets the detailed information for a given pipeline run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineRun or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], + **kwargs: Any + ) -> _models.PipelineRun: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pipeline_run_create_parameters, (IO, bytes)): + _content = pipeline_run_create_parameters + else: + _json = self._serialize.body(pipeline_run_create_parameters, "PipelineRun") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PipelineRun", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: _models.PipelineRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun + :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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Required. + :type pipeline_run_create_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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + pipeline_run_name: str, + pipeline_run_create_parameters: Union[_models.PipelineRun, IO], + **kwargs: Any + ) -> LROPoller[_models.PipelineRun]: + """Creates a pipeline run for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :param pipeline_run_create_parameters: The parameters for creating a pipeline run. Is either a + model type or a IO type. Required. + :type pipeline_run_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun 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 PipelineRun or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PipelineRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PipelineRun] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + pipeline_run_create_parameters=pipeline_run_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PipelineRun", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a pipeline run from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param pipeline_run_name: The name of the pipeline run. Required. + :type pipeline_run_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + pipeline_run_name=pipeline_run_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..a669e33e4bd3 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,774 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List all private endpoint connections in a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2023_01_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Required. + :type private_endpoint_connection: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + registry_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the container + registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The parameters for creating a private endpoint connection. + Is either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.containerregistry.v2023_01_01_preview.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 + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified private endpoint connection associated with the container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_registries_operations.py new file mode 100644 index 000000000000..7aeb0198cf44 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_registries_operations.py @@ -0,0 +1,2406 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_import_image_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", + ) # 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", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_usages_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_private_link_resources_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_private_link_resource_request( + resource_group_name: str, registry_name: str, group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_credential_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_credentials_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class RegistriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`registries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _import_image_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImportImageParameters") + + request = build_import_image_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._import_image_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _import_image_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def begin_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: _models.ImportImageParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportImageParameters + :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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. 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_import_image( + self, + resource_group_name: str, + registry_name: str, + parameters: Union[_models.ImportImageParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Copies an image to this container registry from the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param parameters: The parameters specifying the image to copy and the source container + registry. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ImportImageParameters 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: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._import_image_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_import_image.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + } + + @overload + def check_name_availability( + self, + registry_name_check_request: _models.RegistryNameCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameCheckRequest + :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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, registry_name_check_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Required. + :type registry_name_check_request: 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO], **kwargs: Any + ) -> _models.RegistryNameStatus: + """Checks whether the container registry name is available for use. The name must contain only + alphanumeric characters, be globally unique, and between 5 and 50 characters in length. + + :param registry_name_check_request: The object containing information for the availability + request. Is either a model type or a IO type. Required. + :type registry_name_check_request: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameCheckRequest 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: RegistryNameStatus or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryNameStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryNameStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_name_check_request, (IO, bytes)): + _content = registry_name_check_request + else: + _json = self._serialize.body(registry_name_check_request, "RegistryNameCheckRequest") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryNameStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + } + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: + """Lists all the container registries under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Registry"]: + """Lists all the container registries under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Registry or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegistryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> _models.Registry: + """Gets the properties of the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Registry or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _create_initial( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry, (IO, bytes)): + _content = registry + else: + _json = self._serialize.body(registry, "Registry") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: _models.Registry, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + registry: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Required. + :type registry: 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO], **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Creates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry: The parameters for creating a container registry. Is either a model type or a + IO type. Required. + :type registry: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry=registry, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> _models.Registry: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(registry_update_parameters, (IO, bytes)): + _content = registry_update_parameters + else: + _json = self._serialize.body(registry_update_parameters, "RegistryUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Registry", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Registry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: _models.RegistryUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUpdateParameters + :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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Required. + :type registry_update_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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + registry_update_parameters: Union[_models.RegistryUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Registry]: + """Updates a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param registry_update_parameters: The parameters for updating a container registry. Is either + a model type or a IO type. Required. + :type registry_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUpdateParameters 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 Registry or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Registry] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Registry] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + registry_update_parameters=registry_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Registry", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + } + + @distributed_trace + def list_usages( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryUsageListResult: + """Gets the quota usages for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryUsageListResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryUsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryUsageListResult] = kwargs.pop("cls", None) + + request = build_list_usages_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryUsageListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_usages.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + } + + @distributed_trace + def list_private_link_resources( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Lists the private link resources for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_link_resources_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + } + + @distributed_trace + def get_private_link_resource( + self, resource_group_name: str, registry_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource by a specified group name for a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param group_name: The name of the private link resource. Required. + :type group_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) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_private_link_resource_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resource.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources/{groupName}" + } + + @distributed_trace + def list_credentials( + self, resource_group_name: str, registry_name: str, **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Lists the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + } + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: _models.RegenerateCredentialParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegenerateCredentialParameters + :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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Required. + :type regenerate_credential_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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_credential( + self, + resource_group_name: str, + registry_name: str, + regenerate_credential_parameters: Union[_models.RegenerateCredentialParameters, IO], + **kwargs: Any + ) -> _models.RegistryListCredentialsResult: + """Regenerates one of the login credentials for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param regenerate_credential_parameters: Specifies name of the password which should be + regenerated -- password or password2. Is either a model type or a IO type. Required. + :type regenerate_credential_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegenerateCredentialParameters 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: RegistryListCredentialsResult or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.RegistryListCredentialsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RegistryListCredentialsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_credential_parameters, (IO, bytes)): + _content = regenerate_credential_parameters + else: + _json = self._serialize.body(regenerate_credential_parameters, "RegenerateCredentialParameters") + + request = build_regenerate_credential_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_credential.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryListCredentialsResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_credential.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + } + + def _generate_credentials_initial( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> Optional[_models.GenerateCredentialsResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.GenerateCredentialsResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(generate_credentials_parameters, (IO, bytes)): + _content = generate_credentials_parameters + else: + _json = self._serialize.body(generate_credentials_parameters, "GenerateCredentialsParameters") + + request = build_generate_credentials_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._generate_credentials_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _generate_credentials_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: _models.GenerateCredentialsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsParameters + :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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Required. + :type generate_credentials_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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_generate_credentials( + self, + resource_group_name: str, + registry_name: str, + generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.GenerateCredentialsResult]: + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating credentials. Is either a + model type or a IO type. Required. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsParameters 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 GenerateCredentialsResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.GenerateCredentialsResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GenerateCredentialsResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._generate_credentials_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + generate_credentials_parameters=generate_credentials_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_generate_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_replications_operations.py new file mode 100644 index 000000000000..1dc43c0dbcef --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_replications_operations.py @@ -0,0 +1,1047 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, replication_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "replicationName": _SERIALIZER.url( + "replication_name", replication_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ReplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`replications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Replication"]: + """Lists all the replications for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Replication or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ReplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + } + + @distributed_trace + def get( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> _models.Replication: + """Gets the properties of the specified replication. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Replication or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication, (IO, bytes)): + _content = replication + else: + _json = self._serialize.body(replication, "Replication") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: _models.Replication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Required. + :type replication: 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication: Union[_models.Replication, IO], + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Creates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication: The parameters for creating a replication. Is either a model type or a IO + type. Required. + :type replication: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication=replication, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a replication from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> _models.Replication: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(replication_update_parameters, (IO, bytes)): + _content = replication_update_parameters + else: + _json = self._serialize.body(replication_update_parameters, "ReplicationUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Replication", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Replication", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: _models.ReplicationUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ReplicationUpdateParameters + :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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Required. + :type replication_update_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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + replication_name: str, + replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Replication]: + """Updates a replication for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param replication_name: The name of the replication. Required. + :type replication_name: str + :param replication_update_parameters: The parameters for updating a replication. Is either a + model type or a IO type. Required. + :type replication_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ReplicationUpdateParameters 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 Replication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Replication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Replication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + replication_name=replication_name, + replication_update_parameters=replication_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Replication", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_scope_maps_operations.py new file mode 100644 index 000000000000..c4ee50040417 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_scope_maps_operations.py @@ -0,0 +1,1052 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, scope_map_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "scopeMapName": _SERIALIZER.url( + "scope_map_name", scope_map_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-_]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScopeMapsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`scope_maps` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.ScopeMap"]: + """Lists all the scope maps for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScopeMap or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ScopeMapListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any) -> _models.ScopeMap: + """Gets the properties of the specified scope map. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScopeMap or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_create_parameters, (IO, bytes)): + _content = scope_map_create_parameters + else: + _json = self._serialize.body(scope_map_create_parameters, "ScopeMap") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: _models.ScopeMap, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Required. + :type scope_map_create_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_create_parameters: Union[_models.ScopeMap, IO], + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Creates a scope map for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_create_parameters: The parameters for creating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap 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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_create_parameters=scope_map_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a scope map from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> _models.ScopeMap: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(scope_map_update_parameters, (IO, bytes)): + _content = scope_map_update_parameters + else: + _json = self._serialize.body(scope_map_update_parameters, "ScopeMapUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ScopeMap", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: _models.ScopeMapUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMapUpdateParameters + :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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Required. + :type scope_map_update_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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + scope_map_name: str, + scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ScopeMap]: + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param scope_map_name: The name of the scope map. Required. + :type scope_map_name: str + :param scope_map_update_parameters: The parameters for updating a scope map. Is either a model + type or a IO type. Required. + :type scope_map_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMapUpdateParameters 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 ScopeMap or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.ScopeMap] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopeMap] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + scope_map_update_parameters=scope_map_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopeMap", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_tokens_operations.py new file mode 100644 index 000000000000..61a6fcd5b7e6 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_tokens_operations.py @@ -0,0 +1,1051 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, token_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "tokenName": _SERIALIZER.url( + "token_name", token_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class TokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`tokens` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Token"]: + """Lists all the tokens for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Token or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TokenListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any) -> _models.Token: + """Gets the properties of the specified token. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Token or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_create_parameters, (IO, bytes)): + _content = token_create_parameters + else: + _json = self._serialize.body(token_create_parameters, "Token") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: _models.Token, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Required. + :type token_create_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_create_parameters: Union[_models.Token, IO], + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. Is either a model type or + a IO type. Required. + :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token + 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_create_parameters=token_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a token from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> _models.Token: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(token_update_parameters, (IO, bytes)): + _content = token_update_parameters + else: + _json = self._serialize.body(token_update_parameters, "TokenUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Token", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Token", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: _models.TokenUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenUpdateParameters + :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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Required. + :type token_update_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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + token_name: str, + token_update_parameters: Union[_models.TokenUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Token]: + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param token_name: The name of the token. Required. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. Is either a model type or + a IO type. Required. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.TokenUpdateParameters 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 Token or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Token] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Token] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_update_parameters=token_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Token", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_webhooks_operations.py new file mode 100644 index 000000000000..440d2d6d9daa --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/operations/_webhooks_operations.py @@ -0,0 +1,1391 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, registry_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_update_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ping_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_events_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_callback_config_request( + resource_group_name: str, registry_name: str, webhook_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", + ) # 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", max_length=90, min_length=1 + ), + "registryName": _SERIALIZER.url( + "registry_name", registry_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + "webhookName": _SERIALIZER.url( + "webhook_name", webhook_name, "str", max_length=50, min_length=5, pattern=r"^[a-zA-Z0-9]*$" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebhooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.containerregistry.v2023_01_01_preview.ContainerRegistryManagementClient`'s + :attr:`webhooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterable["_models.Webhook"]: + """Lists all the webhooks for the specified container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Webhook or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WebhookListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + } + + @distributed_trace + def get(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.Webhook: + """Gets the properties of the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Webhook or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _create_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_create_parameters, (IO, bytes)): + _content = webhook_create_parameters + else: + _json = self._serialize.body(webhook_create_parameters, "WebhookCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: _models.WebhookCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookCreateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Required. + :type webhook_create_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_create_parameters: Union[_models.WebhookCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Creates a webhook for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_create_parameters: The parameters for creating a webhook. Is either a model type + or a IO type. Required. + :type webhook_create_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookCreateParameters 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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_create_parameters=webhook_create_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a webhook from a container registry. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + def _update_initial( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> _models.Webhook: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(webhook_update_parameters, (IO, bytes)): + _content = webhook_update_parameters + else: + _json = self._serialize.body(webhook_update_parameters, "WebhookUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Webhook", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Webhook", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: _models.WebhookUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookUpdateParameters + :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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Required. + :type webhook_update_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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + registry_name: str, + webhook_name: str, + webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.Webhook]: + """Updates a webhook with the specified parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :param webhook_update_parameters: The parameters for updating a webhook. Is either a model type + or a IO type. Required. + :type webhook_update_parameters: + ~azure.mgmt.containerregistry.v2023_01_01_preview.models.WebhookUpdateParameters 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 Webhook or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Webhook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + webhook_update_parameters=webhook_update_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Webhook", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + } + + @distributed_trace + def ping(self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any) -> _models.EventInfo: + """Triggers a ping event to be sent to the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventInfo or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.EventInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.EventInfo] = kwargs.pop("cls", None) + + request = build_ping_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.ping.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + ping.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + } + + @distributed_trace + def list_events( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> Iterable["_models.Event"]: + """Lists recent events for the specified webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_01_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_events_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_events.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_events.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + } + + @distributed_trace + def get_callback_config( + self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any + ) -> _models.CallbackConfig: + """Gets the configuration of service URI and custom headers for the webhook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param registry_name: The name of the container registry. Required. + :type registry_name: str + :param webhook_name: The name of the webhook. Required. + :type webhook_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CallbackConfig or the result of cls(response) + :rtype: ~azure.mgmt.containerregistry.v2023_01_01_preview.models.CallbackConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2023-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2023-01-01-preview") + ) + cls: ClsType[_models.CallbackConfig] = kwargs.pop("cls", None) + + request = build_get_callback_config_request( + resource_group_name=resource_group_name, + registry_name=registry_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_callback_config.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CallbackConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_callback_config.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + } diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file